I have an overloaded function that instantiates a class:
fromtypingimportAny, Type, TypeVar, overloadT=TypeVar('T')
@overloaddefmake(cls: Type[T]) ->T:
pass@overloaddefmake() ->Any:
passdefmake(cls=None):
ifcls:
returncls()
returnobject()
c=make(int)
reveal_type(c)Type checking with mypy (using latest from master branch) results in the error:
[out]
a.py:17: error: No overload variant of "make" matches argument types [Overload(def (x: typing.SupportsInt =) -> builtins.int, def (x: Union[builtins.str, builtins.bytes], base: builtins.int =) -> builtins.int)]
a.py:19: error: Revealed type is 'Any'
Removing the overload prevents the error:
fromtypingimportType, TypeVarT=TypeVar('T')
defmake(cls: Type[T]) ->T:
returncls()
c=make(int)Is this a bug or user error?
thanks!
I have an overloaded function that instantiates a class:
Type checking with mypy (using latest from master branch) results in the error:
Removing the overload prevents the error:
Is this a bug or user error?
thanks!