@@ -1928,11 +1928,45 @@ _testStarUnpackNestedUnderscore.py:16: note: Revealed type is "builtins.list[bui
1928
1928
[case testStrictEqualitywithParamSpec]
1929
1929
# flags: --strict-equality
1930
1930
from typing import Generic
1931
- from typing_extensions import ParamSpec
1931
+ from typing_extensions import Concatenate, ParamSpec
1932
1932
1933
1933
P = ParamSpec("P")
1934
1934
1935
1935
class Foo(Generic[P]): ...
1936
+ class Bar(Generic[P]): ...
1936
1937
1937
- def check (foo1: Foo[[int]], foo2: Foo[[str]]) -> bool:
1938
+ def bad1 (foo1: Foo[[int]], foo2: Foo[[str]]) -> bool:
1938
1939
return foo1 == foo2
1940
+
1941
+ def bad2(foo1: Foo[[int, str]], foo2: Foo[[int, bytes]]) -> bool:
1942
+ return foo1 == foo2
1943
+
1944
+ def bad3(foo1: Foo[[int]], foo2: Foo[[int, int]]) -> bool:
1945
+ return foo1 == foo2
1946
+
1947
+ def bad4(foo: Foo[[int]], bar: Bar[[int]]) -> bool:
1948
+ return foo == bar
1949
+
1950
+ def good1(foo1: Foo[[int]], foo2: Foo[[int]]) -> bool:
1951
+ return foo1 == foo2
1952
+
1953
+ def good2(foo1: Foo[[int]], foo2: Foo[[bool]]) -> bool:
1954
+ return foo1 == foo2
1955
+
1956
+ def good3(foo1: Foo[[int, int]], foo2: Foo[[bool, bool]]) -> bool:
1957
+ return foo1 == foo2
1958
+
1959
+ def good4(foo1: Foo[[int]], foo2: Foo[P], *args: P.args, **kwargs: P.kwargs) -> bool:
1960
+ return foo1 == foo2
1961
+
1962
+ def good5(foo1: Foo[P], foo2: Foo[[int, str, bytes]], *args: P.args, **kwargs: P.kwargs) -> bool:
1963
+ return foo1 == foo2
1964
+
1965
+ def good6(foo1: Foo[Concatenate[int, P]], foo2: Foo[[int, str, bytes]], *args: P.args, **kwargs: P.kwargs) -> bool:
1966
+ return foo1 == foo2
1967
+
1968
+ [out]
1969
+ _testStrictEqualitywithParamSpec.py:11: error: Non-overlapping equality check (left operand type: "Foo[[int]]", right operand type: "Foo[[str]]")
1970
+ _testStrictEqualitywithParamSpec.py:14: error: Non-overlapping equality check (left operand type: "Foo[[int, str]]", right operand type: "Foo[[int, bytes]]")
1971
+ _testStrictEqualitywithParamSpec.py:17: error: Non-overlapping equality check (left operand type: "Foo[[int]]", right operand type: "Foo[[int, int]]")
1972
+ _testStrictEqualitywithParamSpec.py:20: error: Non-overlapping equality check (left operand type: "Foo[[int]]", right operand type: "Bar[[int]]")
0 commit comments