Closed
Description
I'm trying the following code
from typing import Dict, List
def f() -> Dict[None, None]:
return {}
def g() -> List[None]:
return []
a = f()
b = g()
Which reports 4 errors (2 for list and 2 for dict) which I think are all incorrect:
foo.py: note: In function "f":
foo.py:4: error: Incompatible return value type (got Dict[object, object], expected Dict[None, None])
foo.py: note: In function "g":
foo.py:7: error: Incompatible return value type (got List[object], expected List[None])
foo.py: note: At top level:
foo.py:9: error: Need type annotation for variable
foo.py:10: error: Need type annotation for variable
- The error on lines 4, 7 appear to say that the empty container does not match the given type, while it should (the valid values of
Dict[None, None]
should be{}
and{None: None}
, the valid values forList[None]
should be[]
and[None]*
k for any natural number k) - The assignments demand a type annotation, although the type of the expression has been fully specified.
Using generics different than None
works fine.