diff --git a/mypy/checker.py b/mypy/checker.py index 6505100cec6f..ac4b905643ea 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -512,7 +512,17 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: impl_type = inner_type elif isinstance(inner_type, Instance): inner_call = get_proper_type( - find_member('__call__', inner_type, inner_type, is_operator=True) + analyze_member_access( + name='__call__', + typ=inner_type, + context=defn.impl, + is_lvalue=False, + is_super=False, + is_operator=True, + msg=self.msg, + original_type=inner_type, + chk=self, + ), ) if isinstance(inner_call, CallableType): impl_type = inner_call diff --git a/test-data/unit/check-overloading.test b/test-data/unit/check-overloading.test index 49b01e8cfc0f..0a69b46e7641 100644 --- a/test-data/unit/check-overloading.test +++ b/test-data/unit/check-overloading.test @@ -5409,6 +5409,7 @@ def f_e(arg): ... class Bad2: def __getattr__(self, attr): + # __getattr__ is not called for implicit `__call__` if attr == "__call__": return lambda *a, **kw: print(a, kw) raise AttributeError