Closed
Description
I'm getting "Need type annotation for variable" errors which I think are the result of a bug with overloads.
Stub file overload_test.pyi
:
from typing import overload, TypeVar, Any
_T = TypeVar('_T')
@overload
def attr(default: _T = ..., blah: int = ...) -> _T: ...
@overload
def attr(default: Any = ...) -> Any: ...
Test program:
from overload_test import attr
a = attr()
b = attr()
reveal_type(a)
reveal_type(b)
mypy output:
test.py:3: error: Need type annotation for variable
test.py:4: error: Need type annotation for variable
test.py:6: error: Revealed type is 'Any'
test.py:6: error: Cannot determine type of 'a'
test.py:7: error: Revealed type is 'Any'
test.py:7: error: Cannot determine type of 'b'
It may be interesting to note that if I swap the order of the overloads, the "Need type annotation for variable" and "Cannot determine type" errors go away.