We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b82276 commit f2734ccCopy full SHA for f2734cc
marshmallow_dataclass/__init__.py
@@ -1044,8 +1044,13 @@ def _is_generic_alias_of_dataclass(clazz: type) -> bool:
1044
Check if given class is a generic alias of a dataclass, if the dataclass is
1045
defined as `class A(Generic[T])`, this method will return true if `A[int]` is passed
1046
"""
1047
- return typing_inspect.is_generic_type(clazz) and dataclasses.is_dataclass(
1048
- typing_inspect.get_origin(clazz)
+ is_generic = typing_inspect.is_generic_type(clazz)
+ type_arguments = typing_inspect.get_args(clazz)
1049
+ origin_class = typing_inspect.get_origin(clazz)
1050
+ return (
1051
+ is_generic
1052
+ and len(type_arguments) > 0
1053
+ and dataclasses.is_dataclass(origin_class)
1054
)
1055
1056
0 commit comments