Skip to content

Commit 1786aa3

Browse files
bibajzTinche
authored andcommitted
Fix py37-38 structuring of mixed typing/regular generics
1 parent 0846fc6 commit 1786aa3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ History
77
* ``attrs`` and dataclass structuring is now ~25% faster.
88
* Fix an issue structuring bare ``typing.List`` s on Pythons lower than 3.9.
99
(`#209 <https://github.com/python-attrs/cattrs/issues/209>`_)
10+
* Fix structuring bare generics on Pythons lower than 3.9.
11+
(`https://github.com/python-attrs/cattrs/issues/218`)
1012

1113
1.10.0 (2022-01-04)
1214
-------------------

src/cattr/_compat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ def is_mapping(type):
168168
bare_mutable_seq_args = TypingMutableSequence.__args__
169169

170170
def is_bare(type):
171-
args = type.__args__
171+
# Lower-cased generics in 3.7-8 do not have `__args__` attribute.
172+
args = getattr(type, "__args__", None)
172173
return (
173174
args == bare_list_args
174175
or args == bare_seq_args
175176
or args == bare_mapping_args
176177
or args == bare_dict_args
177178
or args == bare_mutable_seq_args
179+
or args is None
178180
)
179181

180182
def is_counter(type):

0 commit comments

Comments
 (0)