Skip to content

Type default parameters with overloads - #8573

Open
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 2 commits into
microsoft:mainfrom
jenshnielsen:fix/add-parameter-overloads
Open

Jens Hedegaard Nielsen (jenshnielsen) wants to merge 2 commits into
microsoft:mainfrom
jenshnielsen:fix/add-parameter-overloads

Conversation

@jenshnielsen

Copy link
Copy Markdown
Collaborator

Model the default Parameter return separately from explicitly supplied parameter subclasses, eliminating the generic cast while retaining precise instrument typing.

Model the default Parameter return separately from explicitly supplied parameter subclasses, eliminating the generic cast while retaining precise instrument typing.

Co-authored-by: Copilot <[email protected]>
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.37%. Comparing base (cc26643) to head (43c1926).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8573      +/-   ##
==========================================
- Coverage   72.37%   72.37%   -0.01%     
==========================================
  Files         307      307              
  Lines       32397    32396       -1     
==========================================
- Hits        23447    23446       -1     
  Misses       8950     8950              

☔ 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.

Mypy infers an unannotated constructor receiver as the enclosing class when resolving add_parameter's Self return type. Explicit self: Self annotations are required to assign the result to Parameter[..., Self] without losing subclass precision for parameter.instrument.

This works around the implicit Self inference limitation tracked in:
python/mypy#14075

Add a regression test covering constructor inference and inherited parameter instrument types. Keep the overload and existing covariance unchanged.

Co-authored-by: Copilot <[email protected]>

log = logging.getLogger(__name__)

# Cannot convert to PEP 695: uses default= which requires PEP 696 (Python 3.13+).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment should not be removed

This branch has not been deployed

No deployments
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