fix(tests): adopt modern-di 3.1 lifecycle, drop deprecated validate= - #8
Merged
Merged
Conversation
Two changes, both from modern-di 3.1. Containers are open from construction in 3.1; 3.0 built them closed. Assertions written against the old contract fail on 3.1.1 - these failures predate this commit and reproduce on main. Preconditions now state the 3.1 contract; where a test subject WAS the lifecycle transition, the container is closed first so the transition stays observable rather than passing vacuously. Container(validate=...) is also a deprecated no-op now that emits ValidateArgumentWarning, so README and examples build the container plain and call container.validate() after setup_di, and tests drop the argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes, both caused by modern-di 3.1 and both needed for this package to be correct against it. This package pins
modern-di>=3,<4, so users and CI pick 3.1 up on a routine upgrade.1. The suite is already red on 3.1 (fixed here)
modern-di3.1 makes a container open from construction — 3.0 built them closed and required an explicitopen(). Assertions written against the old contract now fail. These failures predate this PR: they reproduce onmainwith 3.1.1 installed.The fix keeps each test's actual subject. Where the assertion was only a precondition, it now states the 3.1 one. Where the subject was the lifecycle transition, the container is closed first so the transition stays observable — otherwise the assertion would pass without the signal doing anything.
2. The documented example uses a deprecated no-op
3.1 also made
Container(validate=...)a deprecated no-op that emitsValidateArgumentWarning, moving validation to an explicitcontainer.validate()call:validate=Trueemits aDeprecationWarningon every construction, from copy-pasted official documentation. A suite following modern-di's own readiness recipe (filterwarnings = ["error::DeprecationWarning"]) fails on it.README and
examples/now build the container plain and callcontainer.validate()aftersetup_di— the ordering the core docs prescribe, sincesetup_diregisters this integration's providers. Where the example built the container inline, it is hoisted so it can be validated at all. Tests drop the argument only.Historical
planning/files are left untouched. Suite green after both changes. The docs half matches the pattern reviewed in modern-di-fastapi#37.🤖 Generated with Claude Code