Skip to content

Commit 59f601c

Browse files
committed
Add test case testDeprecatedImportedOverloadedFunction and fix check_call_expr_with_callee_type accordingly.
1 parent 1715085 commit 59f601c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

mypy/checkexpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ def check_call_expr_with_callee_type(
14821482
object_type=object_type,
14831483
)
14841484
proper_callee = get_proper_type(callee_type)
1485-
if isinstance(e.callee, NameExpr):
1485+
if isinstance(e.callee, (NameExpr, MemberExpr)):
14861486
self.chk.warn_deprecated_overload_item(e.callee.node, e, target=callee_type)
14871487
if isinstance(e.callee, RefExpr) and isinstance(proper_callee, CallableType):
14881488
# Cache it for find_isinstance_check()

test-data/unit/check-deprecated.test

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,26 @@ h(1.0) # E: No overload variant of "h" matches argument type "float" \
595595
# N: def h(x: str) -> str
596596

597597
[builtins fixtures/tuple.pyi]
598+
599+
600+
[case testDeprecatedImportedOverloadedFunction]
601+
602+
import m
603+
604+
m.g
605+
m.g(1) # N: overload def (x: builtins.int) -> builtins.int of function m.g is deprecated: work with str instead
606+
m.g("x")
607+
608+
[file m.py]
609+
610+
from typing import Union
611+
from typing_extensions import deprecated, overload
612+
613+
@overload
614+
@deprecated("work with str instead")
615+
def g(x: int) -> int: ...
616+
@overload
617+
def g(x: str) -> str: ...
618+
def g(x: Union[int, str]) -> Union[int, str]: ...
619+
620+
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)