@@ -2073,6 +2073,38 @@ main:14: note: Got:
2073
2073
main:14: note: def g(self, x: str) -> None
2074
2074
main:14: note: <2 more conflict(s) not shown>
2075
2075
2076
+ [case testProtocolIncompatibilityWithUnionType]
2077
+ from typing import Any, Optional, Protocol
2078
+
2079
+ class A(Protocol):
2080
+ def execute(self, statement: Any, *args: Any, **kwargs: Any) -> None: ...
2081
+
2082
+ class B(Protocol):
2083
+ def execute(self, stmt: Any, *args: Any, **kwargs: Any) -> None: ...
2084
+ def cool(self) -> None: ...
2085
+
2086
+ def func1(arg: A) -> None: ...
2087
+ def func2(arg: Optional[A]) -> None: ...
2088
+
2089
+ x: B
2090
+ func1(x)
2091
+ func2(x)
2092
+ [builtins fixtures/tuple.pyi]
2093
+ [builtins fixtures/dict.pyi]
2094
+ [out]
2095
+ main:14: error: Argument 1 to "func1" has incompatible type "B"; expected "A"
2096
+ main:14: note: Following member(s) of "B" have conflicts:
2097
+ main:14: note: Expected:
2098
+ main:14: note: def execute(self, statement: Any, *args: Any, **kwargs: Any) -> None
2099
+ main:14: note: Got:
2100
+ main:14: note: def execute(self, stmt: Any, *args: Any, **kwargs: Any) -> None
2101
+ main:15: error: Argument 1 to "func2" has incompatible type "B"; expected "Optional[A]"
2102
+ main:15: note: Following member(s) of "B" have conflicts:
2103
+ main:15: note: Expected:
2104
+ main:15: note: def execute(self, statement: Any, *args: Any, **kwargs: Any) -> None
2105
+ main:15: note: Got:
2106
+ main:15: note: def execute(self, stmt: Any, *args: Any, **kwargs: Any) -> None
2107
+
2076
2108
[case testDontShowNotesForTupleAndIterableProtocol]
2077
2109
from typing import Iterable, Sequence, Protocol, NamedTuple
2078
2110
0 commit comments