Skip to content

feat: support modern-di 4 - #43

Merged
lesnik512 merged 2 commits into
mainfrom
modern-di-4
Oct 9, 2026
Merged

lesnik512 merged 2 commits into
mainfrom
modern-di-4

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Refs modern-python/modern-di#579.
Closes #42

Summary

  • Widen the requirement to modern-di>=3.1,<5.
  • tests/test_lifespan.py: test_restart_reopens_without_warning filtered exceptions.ContainerClosedWarning, which modern-di 4.0 removes. The test is now test_restart_reopens_root. It enqueues a job for the second worker cycle and asserts the job result. In 4.0 a resolve from a closed root raises ContainerClosedError, so the job fails if on_startup stops reopening the root. The old version ran no job in the second cycle, so it never resolved anything from the reopened root.

Verification

  • 3.x (modern-di 3.6.0 from PyPI): eof-fixer, ruff format/check and ty pass; pytest 22 passed, coverage 100%.
  • 4.0 (modern-di main f300c2e from a local wheel): ty passes; pytest 22 passed, coverage 100%.
  • With container.open() removed from on_startup, the new test fails under 4.0 because the job raised ContainerClosedError.

This PR stays a draft until modern-di 4.0.0 is on PyPI.

Widen the requirement to modern-di>=3.1,<5. test_restart_reopens_root now runs a job in the second worker cycle instead of filtering ContainerClosedWarning, which 4.0 removes.
@lesnik512
lesnik512 marked this pull request as ready for review October 9, 2026 18:01
@lesnik512
lesnik512 merged commit 4c9c77f into main Oct 9, 2026
10 checks passed
@lesnik512
lesnik512 deleted the modern-di-4 branch October 9, 2026 18:03
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.

Prepare for modern-di 4.0: rewrite test_restart_reopens_without_warning

1 participant