Skip to content

Commit 950173a

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

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

mypy/checker.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 7 deletions
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],

test-data/unit/check-classes.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ class B:
19751975
a = A
19761976
bad = lambda: 42
19771977

1978-
B().bad() # E: Attribute function of type Callable[[], int] does not accept self argument
1978+
B().bad() # E: Attribute function with type Callable[[], int] does not accept self argument
19791979
reveal_type(B.a) # E: Revealed type is 'def () -> __main__.A'
19801980
reveal_type(B().a) # E: Revealed type is 'def () -> __main__.A'
19811981
reveal_type(B().a()) # E: Revealed type is '__main__.A'

0 commit comments

Comments
 (0)