-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-pep-695Issues related to PEP 695 syntaxIssues related to PEP 695 syntaxtopic-type-variables
Description
Bug Report, To Reproduce, & Actual Behaviour
See mypy Playground:
from typing import TypeVar, Protocol, overload
_T1_contra = TypeVar("_T1_contra", contravariant=True)
_T2_contra = TypeVar("_T2_contra", contravariant=True)
class A(Protocol[_T1_contra, _T2_contra]): # E: Contravariant type variable "_T2_contra" used in protocol where covariant one is expected [misc]
@overload
def method(self, a: _T1_contra) -> None: ...
@overload
def method(self, a: _T2_contra) -> None: ...
def method(self, a: object) -> None: ...No errors are emitted if type parameter syntax is used (which should automatically imply contravariance), or if Protocol is replaced by Generic.
Expected Behavior
No errors.
Your Environment
- Mypy version used: 1.18.2
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-pep-695Issues related to PEP 695 syntaxIssues related to PEP 695 syntaxtopic-type-variables