Skip to content

Commit

Permalink
Attempt fixing tests on 3.7/3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Jan 22, 2021
1 parent 32fd3c7 commit b788cc8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/cattr/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_origin(cl):
from typing import Union, _GenericAlias

def is_tuple(type):
return type is Tuple or (
return type in (Tuple, tuple) or (
type.__class__ is _GenericAlias
and issubclass(type.__origin__, Tuple)
)
Expand All @@ -48,24 +48,26 @@ def is_union_type(obj):
)

def is_sequence(type: Any) -> bool:
return type is List or (
return type in (List, list) or (
type.__class__ is _GenericAlias
and type.__origin__ is not Union
and issubclass(type.__origin__, Sequence)
)

def is_mutable_set(type):
return type.__class__ is _GenericAlias and issubclass(
type.__origin__, MutableSet
return type is set or (
type.__class__ is _GenericAlias
and issubclass(type.__origin__, MutableSet)
)

def is_frozenset(type):
return type.__class__ is _GenericAlias and issubclass(
type.__origin__, FrozenSet
return type is frozenset or (
type.__class__ is _GenericAlias
and issubclass(type.__origin__, FrozenSet)
)

def is_mapping(type):
return type is Mapping or (
return type in (Mapping, dict) or (
type.__class__ is _GenericAlias
and issubclass(type.__origin__, Mapping)
)
Expand Down

0 comments on commit b788cc8

Please sign in to comment.