Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions runtype/pytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def __repr__(self):

Object = PythonDataType(object)
Iter = SequenceType(PythonDataType(collections.abc.Iterable))
OrderedDict = DictType(PythonDataType(collections.OrderedDict), variance=Variance.Invariant)
Sequence = SequenceType(PythonDataType(abc.Sequence))
List = SequenceType(PythonDataType(list), variance=Variance.Invariant)
MutableSequence = SequenceType(PythonDataType(abc.MutableSequence), variance=Variance.Invariant)
Expand Down Expand Up @@ -486,6 +487,7 @@ def cast_from(self, obj):
set: Set,
frozenset: FrozenSet,
dict: Dict,
collections.OrderedDict: OrderedDict,
tuple: Tuple,
bool: Bool,
None: NoneType,
Expand Down Expand Up @@ -633,6 +635,9 @@ def _to_canon(self, t):
return Type[self.to_canon(t)]
# TODO test issubclass on t.__args__
return Type
elif origin is collections.OrderedDict:
a, b = args
return OrderedDict[to_canon(a), to_canon(b)]
elif isinstance(t, typing._GenericAlias):
return self._to_canon(origin)

Expand Down