[ty] Support variance keywords in ParamSpec#24927
Merged
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 88.79%. The percentage of expected errors that received a diagnostic held steady at 84.63%. The number of fully passing files held steady at 84/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownsphinx
trio
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unresolved-attribute |
0 | 0 | 5 |
invalid-argument-type |
0 | 1 | 0 |
invalid-return-type |
0 | 0 | 1 |
| Total | 0 | 1 | 6 |
Raw diff:
antidote (https://github.com/Finistere/antidote)
- src/antidote/core/_inject.py:295:36 error[invalid-argument-type] Argument to `classmethod.__init__` is incorrect: Expected `(type[Unknown], /, *args: object, **kwargs: object) -> object`, found `Top[(...) -> object]`
- src/antidote/core/_injection.py:298:9 error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]]` has no attribute `__qualname__`
+ src/antidote/core/_injection.py:298:9 error[unresolved-attribute] Object of type `((...) -> object) & ~Top[staticmethod[(...), object]] & ~Top[classmethod[Unknown, (...), object]]` has no attribute `__qualname__`
- src/antidote/core/_injection.py:298:30 error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]]` has no attribute `__name__`
+ src/antidote/core/_injection.py:298:30 error[unresolved-attribute] Object of type `((...) -> object) & ~Top[staticmethod[(...), object]] & ~Top[classmethod[Unknown, (...), object]]` has no attribute `__name__`
- src/antidote/core/_injection.py:302:17 error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]] & ~MethodType` has no attribute `__qualname__`
+ src/antidote/core/_injection.py:302:17 error[unresolved-attribute] Object of type `((...) -> object) & ~Top[staticmethod[(...), object]] & ~Top[classmethod[Unknown, (...), object]] & ~MethodType` has no attribute `__qualname__`
- src/antidote/core/_injection.py:302:42 error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]] & ~MethodType` has no attribute `__name__`
+ src/antidote/core/_injection.py:302:42 error[unresolved-attribute] Object of type `((...) -> object) & ~Top[staticmethod[(...), object]] & ~Top[classmethod[Unknown, (...), object]] & ~MethodType` has no attribute `__name__`
discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/errors.py:453:95 error[unresolved-attribute] Object of type `Top[(...) -> Coroutine[Any, Any, object]]` has no attribute `__qualname__`
+ discord/app_commands/errors.py:453:95 error[unresolved-attribute] Object of type `((Interaction[Any], /, *args: Unknown, **kwargs: Unknown) -> Coroutine[Any, Any, object]) | ((Any, Interaction[Any], /, *args: Any, **kwargs: Any) -> Coroutine[Any, Any, Any])` has no attribute `__qualname__`
strawberry (https://github.com/strawberry-graphql/strawberry)
- strawberry/types/fields/resolver.py:417:20 error[invalid-return-type] Return type does not match returned value: expected `(...) -> T@StrawberryResolver`, found `Top[(...) -> object]`
+ strawberry/types/fields/resolver.py:417:20 error[invalid-return-type] Return type does not match returned value: expected `(...) -> T@StrawberryResolver`, found `(...) -> object`565a643 to
8f98f40
Compare
ParamSpec
carljm
approved these changes
Apr 29, 2026
| (true, false, false) => Some(TypeVarVariance::Covariant), | ||
| (false, true, false) => Some(TypeVarVariance::Contravariant), | ||
| (false, false, false) => Some(TypeVarVariance::Invariant), | ||
| (false, false, true) => None, |
Contributor
There was a problem hiding this comment.
If this is all it takes to support infer_variance=True, we should make this change for regular legacy typevars right away! (But in separate PR.)
charliermarsh
added a commit
that referenced
this pull request
Apr 29, 2026
## Summary See: #24927 (comment).
thejchap
pushed a commit
to thejchap/ruff
that referenced
this pull request
May 23, 2026
## Summary This PR adds `covariant`, `contravariant`, and `infer_variance` support to `ParamSpec`. See: python/typing#2215. See: astral-sh#24479 (review).
thejchap
pushed a commit
to thejchap/ruff
that referenced
this pull request
May 23, 2026
## Summary See: astral-sh#24927 (comment).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
covariant,contravariant, andinfer_variancesupport toParamSpec.See: python/typing#2215.
See: #24479 (review).