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
I'm not sure what's going on, better check the example. Also mypy experts, please forgive me if this is intentional behavior and not a bug.
To Reproduce
importtypingclassA: passclassB: passT=typing.TypeVar('T', A, B)
classC(typing.Generic[T]):
defmethod_A(self, argument: T) ->None: passdefmethod_C(self, argument: T) ->typing.Self:
self.method_A(argument)
returnself
Actual Behavior
main.py:13: error: Argument 1 to "method_A" of "C" has incompatible type "A"; expected "T" [arg-type]
main.py:13: error: Argument 1 to "method_A" of "C" has incompatible type "B"; expected "T" [arg-type]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
Mypy version used: mypy 1.0.0+dev.9183b28401bd2928d921a068bbbc7e6565e77649 (compiled: no)
Mypy command-line flags: none required to reproduce
Mypy configuration options from mypy.ini (and other config files): none required to reproduce
Python version used: 3.11
The text was updated successfully, but these errors were encountered:
…es (#14491)
Fixes#14374
It looks like we need to special-case `Self` in `expand_type()` to
support it in generics over `TypeVar` with values, since `Self` is the
only type variable that can legitimately have other type variables in
its upper bound.
Bug Report
I'm not sure what's going on, better check the example. Also mypy experts, please forgive me if this is intentional behavior and not a bug.
To Reproduce
Actual Behavior
Your Environment
mypy.ini
(and other config files): none required to reproduceThe text was updated successfully, but these errors were encountered: