Skip to content

Fix class-level noninjectable constructor exclusions - #331

Open
boyfeiyu wants to merge 5 commits into
python-injector:masterfrom
boyfeiyu:BOYF-25-noninjectable-class-169
Open

boyfeiyu wants to merge 5 commits into
python-injector:masterfrom
boyfeiyu:BOYF-25-noninjectable-class-169

Conversation

@boyfeiyu

Copy link
Copy Markdown

Class-level @noninjectable currently stores exclusions on the class, while injection reads them from __init__. In the dataclass example from #169, foo is therefore injected as 0 despite being explicitly excluded.

Apply class-level exclusions to a copy of the constructor, keeping inherited or shared constructor metadata isolated. Preserve staticmethod/classmethod descriptors and ordinary Python construction. Add regressions for dataclasses and regular classes, decorator order, missing and explicit arguments, inherited/shared constructors, stacked exclusions, and constructor closures/defaults; document dataclass decorator order.

Closes #169.

Validation on macOS arm64 / CPython 3.12.14: 158 pytest/doctest tests passed (97.08% coverage); mypy, Black, check-manifest, and package installation passed. The existing Injector limitation when injecting static/class constructors is unchanged; these descriptor regressions verify ordinary Python construction and metadata isolation.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.93%. Comparing base (3177d40) to head (f333474).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #331      +/-   ##
==========================================
+ Coverage   96.83%   96.93%   +0.09%     
==========================================
  Files           1        1              
  Lines         601      620      +19     
  Branches      103      109       +6     
==========================================
+ Hits          582      601      +19     
  Misses         13       13              
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@boyfeiyu
boyfeiyu force-pushed the BOYF-25-noninjectable-class-169 branch from ba306dc to f333474 Compare November 1, 2026 10:10
@boyfeiyu

boyfeiyu commented Nov 2, 2026

Copy link
Copy Markdown
Author

Fixed the PyPy constructor-copy failure in eec065e. PyPy exposes native object/list initializers as functions with builtin code and no globals dictionary; the copy path now requires Python code and dictionary globals.

On macOS arm64 with PyPy 8.0.1 / Python 3.11.17, the previous head reproduces the four CI failures and this commit passes all 162 tests. CPython 3.11.18 also passes all 162 tests; the 17 focused regressions, type/format checks and packaging checks pass. Ubuntu and the remaining CI matrix still need remote validation.

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.

@noninjectable seems to not work with dataclasses and auto_bind

1 participant