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
mypy tries to infer the type parameters of a generic class even if they are explicitly given.
To Reproduce
fromtypingimportoverloadclassFrobnicator[T]: # Using a TypeVar gives identical results@overloaddef__init__(self, param: T) ->None: ...
@overload# Removing `param` in this case gives identical resultsdef__init__(self: 'Frobnicator[None]', param: None=None) ->None: ...
def__init__(self, param: T|None=None) ->None:
...
Expected Behavior
I expect the following to produce a "missing argument" error (like Pyright 1.1.384 does).
f = Frobnicator[int]()
Actual Behavior
reveal_type(f) shows Frobnicator[None]
Your Environment
The behavior is identical for mypy v1.11.1, v1.11.2 and the master branch, with both Python 3.12 and 3.13. I tried it on my local Arch + pyenv based setup and, using TypeVar, in https://mypy-play.net
The text was updated successfully, but these errors were encountered:
Bug Report
mypy
tries to infer the type parameters of a generic class even if they are explicitly given.To Reproduce
Expected Behavior
I expect the following to produce a "missing argument" error (like Pyright 1.1.384 does).
Actual Behavior
reveal_type(f)
showsFrobnicator[None]
Your Environment
The behavior is identical for mypy v1.11.1, v1.11.2 and the master branch, with both Python 3.12 and 3.13. I tried it on my local Arch + pyenv based setup and, using
TypeVar
, in https://mypy-play.netThe text was updated successfully, but these errors were encountered: