File tree Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -161,25 +161,18 @@ def is_mapping(type):
161
161
and issubclass (type .__origin__ , TypingMapping )
162
162
)
163
163
164
- bare_list_args = List .__args__
165
- bare_seq_args = TypingSequence .__args__
166
- bare_mapping_args = TypingMapping .__args__
167
- bare_dict_args = Dict .__args__
168
- bare_mutable_seq_args = TypingMutableSequence .__args__
169
- bare_tuple_args = Tuple .__args__
164
+ bare_generic_args = {
165
+ List .__args__ ,
166
+ TypingSequence .__args__ ,
167
+ TypingMapping .__args__ ,
168
+ Dict .__args__ ,
169
+ TypingMutableSequence .__args__ ,
170
+ Tuple .__args__ ,
171
+ None , # non-parametrized containers do not have `__args__ attribute in py3.7-8
172
+ }
170
173
171
174
def is_bare (type ):
172
- # Lower-cased generics in 3.7-8 do not have `__args__` attribute.
173
- args = getattr (type , "__args__" , None )
174
- return (
175
- args == bare_list_args
176
- or args == bare_seq_args
177
- or args == bare_mapping_args
178
- or args == bare_dict_args
179
- or args == bare_mutable_seq_args
180
- or args == bare_tuple_args
181
- or args is None
182
- )
175
+ return getattr (type , "__args__" , None ) in bare_generic_args
183
176
184
177
def is_counter (type ):
185
178
return (
You can’t perform that action at this time.
0 commit comments