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
# E: Argument 1 of "__replace__" is incompatible with supertype "A"; supertype defines the argument type as "Optional[str]" [override] \
772
+
# E: Argument 1 of "__replace__" is incompatible with supertype "A"; supertype defines the argument type as "str | None" [override] \
773
773
# N: This violates the Liskov substitution principle \
774
774
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
775
775
[builtins fixtures/tuple.pyi]
@@ -899,18 +899,18 @@ class A:
899
899
f4: Union[Callable[[str], str], str]
900
900
901
901
class B(A):
902
-
def f1(self, x: str) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Union[Callable[[str], str], str]", override has type "Callable[[str], str]")
902
+
def f1(self, x: str) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], str] | str", override has type "Callable[[str], str]")
903
903
pass
904
904
905
-
def f2(self, x: object) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Union[Callable[[str], str], str]", override has type "Callable[[object], str]")
905
+
def f2(self, x: object) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], str] | str", override has type "Callable[[object], str]")
906
906
pass
907
907
908
908
@classmethod
909
-
def f3(cls, x: str) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Union[Callable[[str], str], str]", override has type "Callable[[str], str]")
909
+
def f3(cls, x: str) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], str] | str", override has type "Callable[[str], str]")
910
910
pass
911
911
912
912
@staticmethod
913
-
def f4(x: str) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Union[Callable[[str], str], str]", override has type "Callable[[str], str]")
913
+
def f4(x: str) -> str: # E: Covariant override of a mutable attribute (base class "A" defined the type as "Callable[[str], str] | str", override has type "Callable[[str], str]")
914
914
pass
915
915
[builtins fixtures/classmethod.pyi]
916
916
@@ -1149,10 +1149,10 @@ T = TypeVar('T')
1149
1149
def join(x: T, y: T) -> T: pass
1150
1150
1151
1151
f1 = join(func, WithMetaclass)
1152
-
reveal_type(f1()) # N: Revealed type is "Union[__main__.WithMetaclass, None]"
1152
+
reveal_type(f1()) # N: Revealed type is "__main__.WithMetaclass | None"
1153
1153
1154
1154
f2 = join(WithMetaclass, func)
1155
-
reveal_type(f2()) # N: Revealed type is "Union[__main__.WithMetaclass, None]"
1155
+
reveal_type(f2()) # N: Revealed type is "__main__.WithMetaclass | None"
1156
1156
1157
1157
-- Attribute access in class body
1158
1158
-- ------------------------------
@@ -2829,9 +2829,9 @@ a: Union[int, float]
2829
2829
b: int
2830
2830
c: float
2831
2831
2832
-
reveal_type(a + a) # N: Revealed type is "Union[builtins.int, builtins.float]"
2833
-
reveal_type(a + b) # N: Revealed type is "Union[builtins.int, builtins.float]"
2834
-
reveal_type(b + a) # N: Revealed type is "Union[builtins.int, builtins.float]"
2832
+
reveal_type(a + a) # N: Revealed type is "builtins.int | builtins.float"
2833
+
reveal_type(a + b) # N: Revealed type is "builtins.int | builtins.float"
2834
+
reveal_type(b + a) # N: Revealed type is "builtins.int | builtins.float"
2835
2835
reveal_type(a + c) # N: Revealed type is "builtins.float"
2836
2836
reveal_type(c + a) # N: Revealed type is "builtins.float"
2837
2837
[builtins fixtures/ops.pyi]
@@ -2877,16 +2877,16 @@ a + a # E: Unsupported operand types for + ("Foo" and "Bar") \
2877
2877
# N: Both left and right operands are unions
2878
2878
2879
2879
a + b # E: Unsupported operand types for + ("Bar" and "Foo") \
2880
-
# N: Left operand is of type "Union[Foo, Bar]"
2880
+
# N: Left operand is of type "Foo | Bar"
2881
2881
2882
2882
b + a # E: Unsupported operand types for + ("Foo" and "Bar") \
2883
-
# N: Right operand is of type "Union[Foo, Bar]"
2883
+
# N: Right operand is of type "Foo | Bar"
2884
2884
2885
2885
a + c # E: Unsupported operand types for + ("Foo" and "Bar") \
2886
-
# N: Left operand is of type "Union[Foo, Bar]"
2886
+
# N: Left operand is of type "Foo | Bar"
2887
2887
2888
2888
c + a # E: Unsupported operand types for + ("Bar" and "Foo") \
2889
-
# N: Right operand is of type "Union[Foo, Bar]"
2889
+
# N: Right operand is of type "Foo | Bar"
2890
2890
2891
2891
[case testOperatorDoubleUnionNoRelationship2]
2892
2892
from typing import Union
@@ -2903,9 +2903,9 @@ a: Union[Foo, Bar]
2903
2903
b: Foo
2904
2904
c: Bar
2905
2905
2906
-
reveal_type(a + a) # N: Revealed type is "Union[__main__.Foo, __main__.Bar]"
2907
-
reveal_type(a + b) # N: Revealed type is "Union[__main__.Foo, __main__.Bar]"
2908
-
reveal_type(b + a) # N: Revealed type is "Union[__main__.Foo, __main__.Bar]"
2906
+
reveal_type(a + a) # N: Revealed type is "__main__.Foo | __main__.Bar"
2907
+
reveal_type(a + b) # N: Revealed type is "__main__.Foo | __main__.Bar"
2908
+
reveal_type(b + a) # N: Revealed type is "__main__.Foo | __main__.Bar"
2909
2909
reveal_type(a + c) # N: Revealed type is "__main__.Bar"
2910
2910
reveal_type(c + a) # N: Revealed type is "__main__.Bar"
2911
2911
@@ -2946,11 +2946,11 @@ class D:
2946
2946
x: Union[A, B]
2947
2947
y: Union[C, D]
2948
2948
2949
-
reveal_type(x + y) # N: Revealed type is "Union[__main__.Out3, __main__.Out1, __main__.Out2, __main__.Out4]"
2950
-
reveal_type(A() + y) # N: Revealed type is "Union[__main__.Out3, __main__.Out1]"
2951
-
reveal_type(B() + y) # N: Revealed type is "Union[__main__.Out2, __main__.Out4]"
2952
-
reveal_type(x + C()) # N: Revealed type is "Union[__main__.Out3, __main__.Out2]"
2953
-
reveal_type(x + D()) # N: Revealed type is "Union[__main__.Out1, __main__.Out4]"
2949
+
reveal_type(x + y) # N: Revealed type is "__main__.Out3 | __main__.Out1 | __main__.Out2 | __main__.Out4"
2950
+
reveal_type(A() + y) # N: Revealed type is "__main__.Out3 | __main__.Out1"
2951
+
reveal_type(B() + y) # N: Revealed type is "__main__.Out2 | __main__.Out4"
2952
+
reveal_type(x + C()) # N: Revealed type is "__main__.Out3 | __main__.Out2"
2953
+
reveal_type(x + D()) # N: Revealed type is "__main__.Out1 | __main__.Out4"
0 commit comments