File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -971,24 +971,21 @@ def _get_expanded_attr_types(
971
971
parent_typ : ProperType ,
972
972
) -> list [Mapping [str , Type ]] | None :
973
973
"""
974
- For a given type, determine what attrs classes it can be, and return the field types for each class .
974
+ For a given type, determine what attrs classes it can be: for each class, return the field types.
975
975
For generic classes, the field types are expanded.
976
976
If the type contains Any or a non-attrs type, returns None; in the latter case, also reports an error.
977
977
"""
978
978
if isinstance (typ , AnyType ):
979
979
return None
980
980
if isinstance (typ , UnionType ):
981
981
types = []
982
- had_errors = False
983
982
for item in typ .relevant_items ():
984
983
item = get_proper_type (item )
985
984
item_types = _get_expanded_attr_types (ctx , item , item , parent_typ )
986
- if isinstance ( item_types , list ) :
985
+ if types is not None and item_types is not None :
987
986
types += item_types
988
987
else :
989
- had_errors = True
990
- if had_errors :
991
- return None
988
+ types = None # but keep iterating to emit all errors
992
989
return types
993
990
if isinstance (typ , TypeVarType ):
994
991
return _get_expanded_attr_types (
You can’t perform that action at this time.
0 commit comments