Skip to content

Commit 28a47aa

Browse files
onursaticimvanderlee
authored andcommitted
support py3.6
1 parent 52e25f8 commit 28a47aa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

marshmallow_dataclass/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,13 @@ def _is_generic_alias_of_dataclass(clazz: type) -> bool:
854854
Check if given class is a generic alias of a dataclass, if the dataclass is
855855
defined as `class A(Generic[T])`, this method will return true if `A[int]` is passed
856856
"""
857-
return typing_inspect.is_generic_type(clazz) and dataclasses.is_dataclass(
858-
typing_inspect.get_origin(clazz)
857+
is_generic = typing_inspect.is_generic_type(clazz)
858+
type_arguments = typing_inspect.get_args(clazz)
859+
origin_class = typing_inspect.get_origin(clazz)
860+
return (
861+
is_generic
862+
and len(type_arguments) > 0
863+
and dataclasses.is_dataclass(origin_class)
859864
)
860865

861866

0 commit comments

Comments
 (0)