Skip to content

feat!: require modern-di 4 and look up providers with Container.find_provider - #39

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.

Summary

  • modern_di_grpc/main.py and tests/test_inject.py call container.find_provider(ServicerContext). modern-di 4.0 makes providers_registry private and adds find_provider as its public replacement.
  • find_provider exists only in 4.0, so the requirement is now modern-di>=4,<5. This drops 3.x support, hence feat!.
  • tests/dependencies.py: the comment on _make_context_reader described 3.x optional-context behaviour. In 4.0 a registered ContextProvider with no value raises ContextValueNotSetError, so the None default only applies in a container where no DIInterceptor registered grpc_context_provider. The comment now says that.

Verification

  • 3.x: skipped. The lower bound is >=4 and find_provider does not exist in 3.x.
  • 4.0: modern-di main (f300c2e) installed from a local wheel. ruff format/check, eof-fixer and ty pass; pytest 30 passed, coverage 100%.

CI will fail to resolve dependencies until modern-di 4.0.0 is on PyPI. This PR stays a draft until then.

…provider

modern-di 4.0 makes Container.providers_registry private and adds Container.find_provider. Reword the test helper comment for the 4.0 rule that a registered ContextProvider with no value raises.
@lesnik512
lesnik512 marked this pull request as ready for review October 9, 2026 18:01
@lesnik512
lesnik512 merged commit 055517b into main Oct 9, 2026
21 of 30 checks passed
@lesnik512
lesnik512 deleted the modern-di-4 branch October 9, 2026 18:04
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