You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error messages, docstrings, CI and test cleanups found in the third pre-4.0 audit #618
This was generated by AI during a third pre-4.0 audit of main at f6e343d.
Non-breaking improvements found in the same audit. None block 4.0.0.
Error messages
Subclassing a provider fails at first resolve with a bare TypeError: no compiled resolver for provider type MyF, and validate() says nothing. Reject at definition time (__init_subclass__) or raise a ModernDIError. tests/test_container.py:224 subclasses Factory.
DuplicateProviderTypeError does not name the two clashing providers, though ProvidersRegistry._add has both; add them with their definition sites. Its second hint ("pass dependencies via kwargs") does not fix a duplicate.
FinalizerError prints [ValueError('boom'), ...] without saying whose finalizer failed. add_note each inner error with the instance type, and use the one-line summary style of ValidationFailedError.
Readability
No docstrings on Factory, Alias, Group, AbstractProvider, CacheSettings, Group.get_providers, get_named_providers; IDE hover shows nothing.
Action versions: actions/cache@v4 (Node 20 deprecation warning in the benchmarks job), setup-uv v8.2.0, actions/checkout v6. Add dependabot for GitHub Actions.
Benchmarks: the C-series never runs in CI; a --benchmark-disable smoke run (33 tests, about 1 s) in scheduled.yml would catch breakage. The G-series baseline cache key ignores the Python version. Nothing alerts on pushes to main (comment-on-alert: false).
Run the Python code blocks in docs/ and README (190 blocks): ast.parse all, execute those importing only modern-di.
--cov-report xml writes a file nothing uploads. fix = true with unsafe-fixes = true makes a bare ruff check apply unsafe fixes. benchmarks/comparative is neither linted nor type-checked.
Tests
test_container.py:755assert gc.collect() == 0 depends on global state and adds nothing. test_types_parser.py:252 asserts only provider is not None. ty flags tests/test_types_parser.py:402 on 3.12+.
test_container.py (1200 lines) and test_context_provider.py (1287 lines) mix topics; move export checks to test_packaging.py and context-leak tests next to the container tests.
Consider a scheduled mutmut run over cache.py, container.py, resolver_compiler.py.
2: DuplicateProviderTypeError names both providers and drops the kwargs hint.
3: each inner FinalizerError exception gets a note naming the instance type.
4: docstrings on Factory, Alias, Group, AbstractProvider, CacheSettings, Group.get_providers and Group.get_named_providers.
6: only actions/cache v4 to v6 in benchmarks.yml. Dependabot and the checkout / setup-uv versions follow the shared workflow template, which no modern-python repo diverges from.
10: only the gc.collect() == 0 assertion. It counts garbage from the whole process, so it will collect once first.
Correction to item 10: test_closed_children_are_freed_without_the_cycle_collector already calls gc.collect() and disables the collector before building the children, so gc.collect() == 0 counts only this test's garbage. No change needed; item 10 is dropped in full.
Activity
lesnik512 commentedon Oct 9, 2026
Triaged against main at 8892421.
Doing:
Factorysubclass gets no validation at all and then fails at first resolve with a bareTypeError.DuplicateProviderTypeErrornames both providers and drops the kwargs hint.FinalizerErrorexception gets a note naming the instance type.Factory,Alias,Group,AbstractProvider,CacheSettings,Group.get_providersandGroup.get_named_providers.actions/cachev4 to v6 inbenchmarks.yml. Dependabot and thecheckout/setup-uvversions follow the shared workflow template, which no modern-python repo diverges from.gc.collect() == 0assertion. It counts garbage from the whole process, so it will collect once first.Dropped: 5, 7, 8, 9, 11, 12, and the rest of 10.
lesnik512 commentedon Oct 9, 2026
Correction to item 10:
test_closed_children_are_freed_without_the_cycle_collectoralready callsgc.collect()and disables the collector before building the children, sogc.collect() == 0counts only this test's garbage. No change needed; item 10 is dropped in full.ci: bump actions/cache to v6 in the benchmarks workflow (#618) (#630)
feat: reject provider subclasses at definition, name both duplicate p…
lesnik512 commentedon Oct 10, 2026
Done: items 1 to 4 in #631, item 6 in #630. #632 fixed the ruff 0.17 lint failure on the way.