Skip to content

Tighten Container init: propagate use_lock, register container_provider under base, reject non-IntEnum scope#193

Merged
lesnik512 merged 1 commit into
mainfrom
container-py-nice-to-have-fixes
Jun 5, 2026
Merged

Tighten Container init: propagate use_lock, register container_provider under base, reject non-IntEnum scope#193
lesnik512 merged 1 commit into
mainfrom
container-py-nice-to-have-fixes

Conversation

@lesnik512
Copy link
Copy Markdown
Member

Summary

Three small `Container` fixes surfaced by the 2026-06-05 bug-hunt audit (nice-to-have items #1, #2, #3 in `planning/audits/2026-06-05-bug-hunt-audit-report.md`).

  • `build_child_container` now propagates `use_lock`. `Container(use_lock=False)` previously got locking back the moment the user descended into a child container, silently undoing the opt-out documented at `docs/providers/factories.md:99-105`. Fixed by forwarding `use_lock=self.lock is not None` to the child constructor.
  • `container_provider` now registers under `Container` (base), not `type(self)`. Subclassing `Container` previously broke the documented auto-injection pattern (`docs/providers/container.md:14-27`): a creator annotated with the literal `Container` class could not be resolved on a subclassed root container, even though the `Self` return types on `build_child_container` / `find_container` indicate subclassing is supported.
  • `Container.init` now rejects non-IntEnum `scope` values up front via a new `InvalidScopeTypeError(ContainerError)`. The signature was already typed `enum.IntEnum` but unenforced; passing `Container(scope=99)` previously succeeded and exploded later from `repr` (or any other site that touched `scope.name`) with a bare `AttributeError`.

Three new regression tests in `tests/test_container.py` cover all three behaviors.

Test plan

  • 3 new tests pass; full suite green (139 passed).
  • 100% coverage maintained.
  • `just lint-ci` green.

🤖 Generated with Claude Code

@lesnik512 lesnik512 self-assigned this Jun 5, 2026
@lesnik512 lesnik512 merged commit 3b02abc into main Jun 5, 2026
7 checks passed
@lesnik512 lesnik512 deleted the container-py-nice-to-have-fixes branch June 5, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant