Skip to content

Commit aed080c

Browse files
committed
rephrase error message, use union_items
1 parent 7aacb4f commit aed080c

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

mypy/checker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def check_reverse_op_method(self, defn: FuncItem, typ: CallableType,
828828
elif isinstance(arg_type, UnionType):
829829
if not arg_type.has_readable_member(other_method):
830830
return
831-
arg_types = list(arg_type.iter_deep())
831+
arg_types = list(union_items(arg_type))
832832
else:
833833
return
834834
# We check that each method is fine when dispatched on a proper self argument

mypy/checkmember.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def check_method_type(functype: FunctionLike, original_type: Type, is_classmetho
373373
for item in functype.items():
374374
if not item.arg_types or item.arg_kinds[0] not in (ARG_POS, ARG_STAR):
375375
# No positional first (self) argument (*args is okay).
376-
msg.fail('Attribute function of type %s does not accept self argument'
376+
msg.fail('Attribute function with type %s does not accept self argument'
377377
% msg.format(item), context)
378378
else:
379379
# Check that self argument has type 'Any' or valid instance/class type.

mypy/types.py

-7
Original file line numberDiff line numberDiff line change
@@ -1130,13 +1130,6 @@ def relevant_items(self) -> List[Type]:
11301130
else:
11311131
return [i for i in self.items if not isinstance(i, NoneTyp)]
11321132

1133-
def iter_deep(self) -> Iterator[Type]:
1134-
for x in self.items:
1135-
if isinstance(x, UnionType):
1136-
yield from x.iter_deep()
1137-
else:
1138-
yield x
1139-
11401133
def serialize(self) -> JsonDict:
11411134
return {'.class': 'UnionType',
11421135
'items': [t.serialize() for t in self.items],

0 commit comments

Comments
 (0)