Skip to content

Add test case for non callable operator with getattr #11637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions test-data/unit/check-overloading.test
Original file line number Diff line number Diff line change
Expand Up @@ -5396,14 +5396,27 @@ def f_d(arg: str) -> None: ...
@dec_d # E: "int" not callable
def f_d(arg): ...

Bad = TypeVar('Good') # type: ignore
Bad1 = TypeVar('Good') # type: ignore

def dec_e(f: Bad) -> Bad: ... # type: ignore
def dec_e(f: Bad1) -> Bad1: ... # type: ignore

@overload
def f_e(arg: int) -> None: ...
@overload
def f_e(arg: str) -> None: ...
@dec_e # E: Bad? not callable
@dec_e # E: Bad1? not callable
def f_e(arg): ...

class Bad2:
def __getattr__(self, attr):
if attr == "__call__":
return lambda *a, **kw: print(a, kw)
raise AttributeError

@overload
def f_f(arg: int) -> None: ...
@overload
def f_f(arg: str) -> None: ...
@Bad2() # E: "Bad2" not callable
def f_f(arg): ...
[builtins fixtures/dict.pyi]