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
Incorrect handling of default arguments for type Type with Typevars #6525
However, if I set default argument for t, mypy fails:
fromtypingimportType, TypeVarMyType=TypeVar('MyType', str, int)
# error: Incompatible default for argument "t" (default has type "Type[str]", argument has type "Type[int]")deffunc(t: Type[MyType] =str) ->MyType:
returnt()
fromtypingimportType, TypeVarMyType=TypeVar('MyType', str, int)
# error: Incompatible default for argument "t" (default has type "Type[int]", argument has type "Type[str]")deffunc(t: Type[MyType] =int) ->MyType:
returnt()
fromtypingimportType, TypeVarMyType=TypeVar('MyType')
# error: Incompatible default for argument "t" (default has type "Type[int]", argument has type "Type[MyType]")deffunc(t: Type[MyType] =int) ->MyType:
returnt()
IMO that's a bug. Without TypeVar it works correctly though:
This is a duplicate of #4236. Please make sure to search the issue tracker when reporting bugs (using a couple of words such as "default" and "generic"/"typevar" then scanning through the listed issues works well).
Activity
emmatyping commentedon Mar 8, 2019
This is a duplicate of #4236. Please make sure to search the issue tracker when reporting bugs (using a couple of words such as "default" and "generic"/"typevar" then scanning through the listed issues works well).