Skip to content

Commit

Permalink
Add test case for non callable operator with getattr (python#11637)
Browse files Browse the repository at this point in the history
Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja authored and tushar-deepsource committed Jan 20, 2022
1 parent 16e32e4 commit e51e58b
Showing 1 changed file with 16 additions and 3 deletions.
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]

0 comments on commit e51e58b

Please sign in to comment.