Closed
Description
When running mypy --strict
against the following code:
from typing import Any, Optional
class Test(object):
def __init__(self) -> None:
self.attr = "foo" # type: Any
def foo(self, do_it: bool) -> Optional[Any]:
if do_it:
return self.attr
else:
return None
I see the following warning:
testcase.py:11: warning: Returning Any from function with declared return type "Union[Any, builtins.None]"
This seems obviously incorrect. At the very least, it's a confusing error message.
Bisecting suggests that this behaviour was introduced in 4141d20.