pytypes
pytypes copied to clipboard
OrderedDict is incompatible with Mapping
The following code:
from collections import OrderedDict
from typing import Mapping
from pytypes import TypeChecker
def f() -> Mapping[int, str]:
return OrderedDict()
with TypeChecker():
f()
fails as follows:
$ python3 Test.py
Traceback (most recent call last):
File "Test.py", line 11, in <module>
f()
File "Test.py", line 8, in f
return OrderedDict()
pytypes.exceptions.ReturnTypeError:
__main__.f
returned incompatible type:
Expected: Mapping[int, str]
Received: OrderedDict
OrderedDict is currently not supported. I don't really want to add new features before Python 3.7 compatibility is achieved. I can see if adding this support is somewhat trivial. Otherwise this has to be postponed.