Skip to content

Commit

Permalink
Add test case testDeprecatedImportedOverloadedFunction and fix `che…
Browse files Browse the repository at this point in the history
…ck_call_expr_with_callee_type` accordingly.
  • Loading branch information
tyralla committed Nov 19, 2024
1 parent 1715085 commit 59f601c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ def check_call_expr_with_callee_type(
object_type=object_type,
)
proper_callee = get_proper_type(callee_type)
if isinstance(e.callee, NameExpr):
if isinstance(e.callee, (NameExpr, MemberExpr)):
self.chk.warn_deprecated_overload_item(e.callee.node, e, target=callee_type)
if isinstance(e.callee, RefExpr) and isinstance(proper_callee, CallableType):
# Cache it for find_isinstance_check()
Expand Down
23 changes: 23 additions & 0 deletions test-data/unit/check-deprecated.test
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,26 @@ h(1.0) # E: No overload variant of "h" matches argument type "float" \
# N: def h(x: str) -> str

[builtins fixtures/tuple.pyi]


[case testDeprecatedImportedOverloadedFunction]

import m

m.g
m.g(1) # N: overload def (x: builtins.int) -> builtins.int of function m.g is deprecated: work with str instead
m.g("x")

[file m.py]

from typing import Union
from typing_extensions import deprecated, overload

@overload
@deprecated("work with str instead")
def g(x: int) -> int: ...
@overload
def g(x: str) -> str: ...
def g(x: Union[int, str]) -> Union[int, str]: ...

[builtins fixtures/tuple.pyi]

0 comments on commit 59f601c

Please sign in to comment.