Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6721b51

Browse files
committed
style
1 parent f466b95 commit 6721b51

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

mypy/plugins/attrs.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -971,24 +971,21 @@ def _get_expanded_attr_types(
971971
parent_typ: ProperType,
972972
) -> list[Mapping[str, Type]] | None:
973973
"""
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.
975975
For generic classes, the field types are expanded.
976976
If the type contains Any or a non-attrs type, returns None; in the latter case, also reports an error.
977977
"""
978978
if isinstance(typ, AnyType):
979979
return None
980980
if isinstance(typ, UnionType):
981981
types = []
982-
had_errors = False
983982
for item in typ.relevant_items():
984983
item = get_proper_type(item)
985984
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:
987986
types += item_types
988987
else:
989-
had_errors = True
990-
if had_errors:
991-
return None
988+
types = None # but keep iterating to emit all errors
992989
return types
993990
if isinstance(typ, TypeVarType):
994991
return _get_expanded_attr_types(

0 commit comments

Comments
 (0)