pytypes icon indicating copy to clipboard operation
pytypes copied to clipboard

OrderedDict is incompatible with Mapping

Open jolaf opened this issue 6 years ago • 1 comments

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

jolaf avatar Aug 26 '19 12:08 jolaf

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.

Stewori avatar Aug 26 '19 15:08 Stewori