You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from typing_extensions import TypeAlias, deprecated, overload
673
+
674
+
class A:
675
+
@overload
676
+
@deprecated("do not pass int")
677
+
def __new__(cls, arg: int) -> A: ...
678
+
@overload
679
+
def __new__(cls, arg: str) -> A: ...
680
+
681
+
class B:
682
+
@overload
683
+
@deprecated("do not pass int")
684
+
def __init__(self, arg: int) -> None: ...
685
+
@overload
686
+
def __init__(self, arg: str) -> None: ...
687
+
688
+
A_alias: TypeAlias = A
689
+
B_alias: TypeAlias = B
690
+
691
+
A(1) # E: overload def (cls: type[__main__.A], arg: builtins.int) -> __main__.A of function __main__.A.__new__ is deprecated: do not pass int
692
+
A_alias(1) # E: overload def (cls: type[__main__.A], arg: builtins.int) -> __main__.A of function __main__.A.__new__ is deprecated: do not pass int
693
+
A("")
694
+
A_alias("")
695
+
class A_child(A):
696
+
def __new__(cls) -> A_child:
697
+
super().__new__(cls, 1) # E: overload def (cls: type[__main__.A], arg: builtins.int) -> __main__.A of function __main__.A.__new__ is deprecated: do not pass int
698
+
super().__new__(cls, "")
699
+
return object.__new__(cls)
700
+
701
+
B(1) # E: overload def (self: __main__.B, arg: builtins.int) of function __main__.B.__init__ is deprecated: do not pass int
702
+
B_alias(1) # E: overload def (self: __main__.B, arg: builtins.int) of function __main__.B.__init__ is deprecated: do not pass int
703
+
B("")
704
+
B_alias("")
705
+
class B_child(B):
706
+
def __init__(self) -> None:
707
+
super().__init__(1) # E: overload def (self: __main__.B, arg: builtins.int) of function __main__.B.__init__ is deprecated: do not pass int
@overload # E: overload def (self: __main__.decorator[def ()], f: def ()) of function __main__.decorator.__init__ is deprecated: decorated function must take arguments
735
+
@decorator
736
+
def f() -> None: ...
737
+
738
+
f()
739
+
f("")
740
+
f(1) # E: No overload variant of "f" matches argument type "int" \
0 commit comments