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
{{ message }}
Repository navigation
Outer type wrongly replaced by inner method definition #14205
map should be builtins.map, not MyClass.map and type should be builtins.type, not MyClass.type
Actual Behavior
method type issue.py:4: error: Function "method type issue.MyClass.map" is not valid as a type [valid-type]
method type issue.py:4: note: Perhaps you need "Callable[...]"
or a callback protocol?
method type issue.py:4: error: Function "method type issue.MyClass.type" is not valid as a type [valid-type]
Found 2 errors in 1 file (checked 1 source file)
The type is taken from the class methods. If I wanted to use the class methods I'd do
(which aren't valid types anyway)
Of course I should use a different name for methods to begin with, but unfortunately I don't have control over that in a type stub.
Your Environment
Mypy version used: 0.990 (compiled: yes)
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Activity
JelleZijlstra commentedon Nov 28, 2022
Mypy is correct here and you'll see the same behavior at runtime. Possible workarounds:
import builtinsand usebuiltins.mapexplicitlyfrom builtins import map as _map(or some other name) and use_mapin annotations_map: TypeAlias = mapin the global scope