diff --git a/python/pluginResources/intellij.python.community.impl.xml b/python/pluginResources/intellij.python.community.impl.xml
index 55085399979a..d290d1913986 100644
--- a/python/pluginResources/intellij.python.community.impl.xml
+++ b/python/pluginResources/intellij.python.community.impl.xml
@@ -683,7 +683,7 @@
-
+
diff --git a/python/testData/inspections/PyTypeCheckerInspection/ForLoopIteration.py b/python/testData/inspections/PyTypeCheckerInspection/ForLoopIteration.py
index 2196ff6c65e3..807bc4926a77 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/ForLoopIteration.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/ForLoopIteration.py
@@ -5,7 +5,7 @@ def test(p1):
for x in 42:
pass
- for x in f('foo', p1):
+ for x in f('foo', p1):
pass
diff --git a/python/testData/inspections/PyTypeCheckerInspection/IterateOverDictValueWhenItsTypeIsUnion.py b/python/testData/inspections/PyTypeCheckerInspection/IterateOverDictValueWhenItsTypeIsUnion.py
index 665923f96eaf..7f786045c9d1 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/IterateOverDictValueWhenItsTypeIsUnion.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/IterateOverDictValueWhenItsTypeIsUnion.py
@@ -3,5 +3,5 @@ KWARGS = {
"little_list": ['WORLD_RET_BP_IMPALA_AB.Control', 'WORLD_RET_BP_IMPALA_AB.Impala_WS'],
}
-for element in KWARGS["little_list"]:
+for element in KWARGS["little_list"]:
print(element)
\ No newline at end of file
diff --git a/python/testData/inspections/PyTypeCheckerInspection/ListLiteralAgainstTypingLiteral.py b/python/testData/inspections/PyTypeCheckerInspection/ListLiteralAgainstTypingLiteral.py
index 2799f9a3d9cf..29a5800a4451 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/ListLiteralAgainstTypingLiteral.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/ListLiteralAgainstTypingLiteral.py
@@ -15,4 +15,5 @@ list_union_literal_incorrect: List[Union[L2, L1]] = ['a', 'r']
list_tuple: List[Tuple[L2, L1]] = [('b', 'test'), (5, 'test')]
-list_tuple_incorrect: List[Tuple[L2, L1]] = [('a',), (5, 'test')]
\ No newline at end of file
+# TODO false negative due to PY-24834
+list_tuple_incorrect: List[Tuple[L2, L1]] = [('a',), (5, 'test')]
\ No newline at end of file
diff --git a/python/testData/inspections/PyTypeCheckerInspection/NotNone.py b/python/testData/inspections/PyTypeCheckerInspection/NotNone.py
index 2f5942613b9c..dd9f2d8806ab 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/NotNone.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/NotNone.py
@@ -14,8 +14,8 @@ def test():
x1 = f1()
x2 = f2()
x3 = 1
- f(x1)
- f(x2)
+ f(x1) # Weaker union types
+ f(x2) # Weaker union types
f(x3)
if x1:
f(x1)
diff --git a/python/testData/inspections/PyTypeCheckerInspection/SetLiteralAgainstTypingLiteral.py b/python/testData/inspections/PyTypeCheckerInspection/SetLiteralAgainstTypingLiteral.py
index a903a0af30ce..23e2a28ea656 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/SetLiteralAgainstTypingLiteral.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/SetLiteralAgainstTypingLiteral.py
@@ -15,4 +15,5 @@ set_union_literal_incorrect: Set[Union[L2, L1]] = {'a', 'r'}
set_of_tuple_and_list: Set[Union[Tuple[L2, L1], List[L1]]] = {('b', 'test'), ['test', 'test'], (5, 'test')}
-set_of_tuple_and_list_incorrect: Set[Union[Tuple[L2, L1], List[L1]]] = {('b', 'r'), ['test', 'test'], (5, 'test')}
\ No newline at end of file
+# TODO false negative due to PY-24834
+set_of_tuple_and_list_incorrect: Set[Union[Tuple[L2, L1], List[L1]]] = {('b', 'r'), ['test', 'test'], (5, 'test')}
\ No newline at end of file
diff --git a/python/testData/inspections/PyTypeCheckerInspection/StrictUnionImplicitProtocolMatching.py b/python/testData/inspections/PyTypeCheckerInspection/StrictUnionImplicitProtocolMatching.py
deleted file mode 100644
index 90f071cfb01c..000000000000
--- a/python/testData/inspections/PyTypeCheckerInspection/StrictUnionImplicitProtocolMatching.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from typing import Any
-
-
-class A:
- def __iter__(self):
- return self
-
- def __next__(self):
- return 42
-
-
-class B:
- def __iter__(self):
- return self
-
- def __next__(self):
- return 42
-
-
-class C:
- pass
-
-
-def all_union_members_match_no_any(iterable: A | B):
- for _ in iterable:
- pass
-
-
-def some_union_members_match_no_any(iterable: A | B | None):
- for _ in iterable:
- pass
-
-
-def all_union_members_dont_match_no_any(iterable: C | None):
- for _ in iterable:
- pass
-
-
-def all_union_members_match_with_any(iterable: A | B | Any):
- for _ in iterable:
- pass
-
-
-def some_union_members_match_with_any(iterable: A | B | None | Any):
- for _ in iterable:
- pass
-
-
-def all_union_members_dont_match_with_any(iterable: C | None | Any):
- for _ in iterable:
- pass
diff --git a/python/testData/inspections/PyTypeCheckerInspection/TypeAssertions.py b/python/testData/inspections/PyTypeCheckerInspection/TypeAssertions.py
index 50307998814c..99a34191b5d4 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/TypeAssertions.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/TypeAssertions.py
@@ -37,8 +37,8 @@ def test():
:type x: int or str
"""
x_1 = f_1()
- print_int(x_1)
- print_int_or_str(x_1)
+ print_int(x_1) # Weaker union types
+ print_int_or_str(x_1) # Weaker union types
if isinstance(x_1, int):
print_int(x_1)
if isinstance(x_1, str):
diff --git a/python/testData/inspections/PyTypeCheckerInspection/UnionReturnTypes.py b/python/testData/inspections/PyTypeCheckerInspection/UnionReturnTypes.py
index 5e146505ae5c..0a9a0263507b 100644
--- a/python/testData/inspections/PyTypeCheckerInspection/UnionReturnTypes.py
+++ b/python/testData/inspections/PyTypeCheckerInspection/UnionReturnTypes.py
@@ -16,7 +16,7 @@ def test(c):
:type x: int
"""
x1 = f1(c)
- f2(x1)
+ f2(x1) # Weaker union types
f3(x1)
f2(x1.count(''))
diff --git a/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py b/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py
index ae1f638cec3e..38e0f79e78d7 100644
--- a/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py
+++ b/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py
@@ -57,7 +57,7 @@ def f():
class MyTestCase(unittest.TestCase):
def test_something(self):
- with self.assertRaises(Exception):
+ with self.assertRaises():
raise Foo
foo() # pass
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFun/a.py b/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFun/a.py
index 5cf05c2b8c2e..7135b2811861 100644
--- a/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFun/a.py
+++ b/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFun/a.py
@@ -6,7 +6,7 @@ async def expect_no_warning():
async def expect_new_warning():
- await fun_non_async()
+ await fun_non_async()
def local_fun_non_async():
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFunReturnAwaitable/a.py b/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFunReturnAwaitable/a.py
index fe94a40833d7..403734c64dd0 100644
--- a/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFunReturnAwaitable/a.py
+++ b/python/testData/inspections/PyUnresolvedReferencesInspection/AsyncAwaitWarningOnImportedFunReturnAwaitable/a.py
@@ -2,7 +2,7 @@ from b import fun_awaitable_imported, MyAwaitable
async def expect_false_positive_warning():
- await fun_awaitable_imported()
+ await fun_awaitable_imported()
async def expect_pass_1():
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/listIndexedByUnknownType.py b/python/testData/inspections/PyUnresolvedReferencesInspection/listIndexedByUnknownType.py
index eba15acbd943..d736117e174f 100644
--- a/python/testData/inspections/PyUnresolvedReferencesInspection/listIndexedByUnknownType.py
+++ b/python/testData/inspections/PyUnresolvedReferencesInspection/listIndexedByUnknownType.py
@@ -1,6 +1,6 @@
def f(i):
xs = []
- xs[i].items()
+ xs[i].items()
def g(index):
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/unionContainingUnknownType.py b/python/testData/inspections/PyUnresolvedReferencesInspection/unionContainingUnknownType.py
index e816b67e8945..46553e364fee 100644
--- a/python/testData/inspections/PyUnresolvedReferencesInspection/unionContainingUnknownType.py
+++ b/python/testData/inspections/PyUnresolvedReferencesInspection/unionContainingUnknownType.py
@@ -1,4 +1,4 @@
def foo(smth, param):
if smth:
param = ""
- print(param.smth())
\ No newline at end of file
+ print(param.smth())
\ No newline at end of file
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberAttributeAccess.py b/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberAttributeAccess.py
deleted file mode 100644
index 2bd363450319..000000000000
--- a/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberAttributeAccess.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from typing import Any
-
-
-class A:
- def method(self):
- pass
-
-class B(A):
- pass
-
-class C:
- def method(self):
- pass
-
-def union_with_all_compatible_types(x: A | B | C):
- x.method()
-
-def union_with_some_incompatible_types(x: A | None):
- x.method()
-
-def union_with_all_incompatible_types(x: object | None):
- x.method()
-
-def union_with_some_incompatible_types_and_any(x: Any | None):
- x.method()
-
-def narrowing_union_with_some_incompatible_types_after(x: Any | None):
- if isinstance(x, A):
- x.method()
- assert isinstance(x, B)
- x.method()
\ No newline at end of file
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberExtendingAny.py b/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberExtendingAny.py
deleted file mode 100644
index 4af4a6f0ae29..000000000000
--- a/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberExtendingAny.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from typing import Any
-
-
-class A:
- a = 1
-
-class Anish(Any):
- pass
-
-a = A() if bool() else Anish()
-
-_ = a.a
-_ = a.b
\ No newline at end of file
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberOperatorAccess.py b/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberOperatorAccess.py
deleted file mode 100644
index da17b4072e92..000000000000
--- a/python/testData/inspections/PyUnresolvedReferencesInspection3K/strictUnionMemberOperatorAccess.py
+++ /dev/null
@@ -1,63 +0,0 @@
-from typing import Any
-
-
-class A:
- def __pos__(self):
- pass
-
- def __add__(self, other):
- pass
-
- def __getitem__(self, item):
- pass
-
-
-class B:
- def __pos__(self):
- pass
-
- def __add__(self, other):
- pass
-
- def __getitem__(self, item):
- pass
-
-
-class C:
- pass
-
-
-def all_union_members_match_no_any(x: A | B):
- print(+x)
- print(x + 1)
- print(x[42])
-
-
-def some_union_members_match_no_any(x: A | B | None):
- print(+x)
- print(x + 1)
- print(x[42])
-
-
-def all_union_members_dont_match_no_any(x: C | None):
- print(+x)
- print(x + 1)
- print(x[42])
-
-
-def all_union_members_match_with_any(x: A | B | Any):
- print(+x)
- print(x + 1)
- print(x[42])
-
-
-def some_union_members_match_with_any(x: A | B | None | Any):
- print(+x)
- print(x + 1)
- print(x[42])
-
-
-def all_union_members_dont_match_with_any(x: C | None | Any):
- print(+x)
- print(x + 1)
- print(x[42])
diff --git a/python/testData/inspections/unusedImport/importExceptImportError/importExceptImportError.py b/python/testData/inspections/unusedImport/importExceptImportError/importExceptImportError.py
index 07483ddd818e..72c6466cad45 100644
--- a/python/testData/inspections/unusedImport/importExceptImportError/importExceptImportError.py
+++ b/python/testData/inspections/unusedImport/importExceptImportError/importExceptImportError.py
@@ -5,7 +5,7 @@ def f(x):
def f(x):
try:
- from foo import StringIO
+ from foo import StringIO
except Exception:
pass
return x
@@ -28,14 +28,14 @@ def f(x):
try:
import foo as bar
except ImportError:
- import bar
+ import bar
# PY-3678
def f():
try:
from foo import bar #pass
except ImportError:
- import bar #fail
+ import bar #fail
finally:
pass
diff --git a/python/testData/refactoring/extractmethod/AwaitExpression.after.withTypes.py b/python/testData/refactoring/extractmethod/AwaitExpression.after.withTypes.py
index 9f6549b6d104..fdf0cfc78a09 100644
--- a/python/testData/refactoring/extractmethod/AwaitExpression.after.withTypes.py
+++ b/python/testData/refactoring/extractmethod/AwaitExpression.after.withTypes.py
@@ -6,5 +6,5 @@ async def foo(x):
return y
-async def bar(x_new) -> Any:
+async def bar(x_new) -> int | Any:
return await x_new + 1
diff --git a/python/testData/refactoring/extractmethod/MethodInnerFuncCombined.after.withTypes.py b/python/testData/refactoring/extractmethod/MethodInnerFuncCombined.after.withTypes.py
index 83745c660a9b..f985efe37174 100644
--- a/python/testData/refactoring/extractmethod/MethodInnerFuncCombined.after.withTypes.py
+++ b/python/testData/refactoring/extractmethod/MethodInnerFuncCombined.after.withTypes.py
@@ -8,6 +8,6 @@ class Test:
y = extracted(c)
return y
- def extracted(c_new) -> Any:
+ def extracted(c_new) -> int | Any:
y = self.a + b * c_new
return y
diff --git a/python/testData/refactoring/extractmethod/MethodInnerFuncWithMethodParam.after.withTypes.py b/python/testData/refactoring/extractmethod/MethodInnerFuncWithMethodParam.after.withTypes.py
index 149aa2b45135..0b31b00265a1 100644
--- a/python/testData/refactoring/extractmethod/MethodInnerFuncWithMethodParam.after.withTypes.py
+++ b/python/testData/refactoring/extractmethod/MethodInnerFuncWithMethodParam.after.withTypes.py
@@ -7,6 +7,6 @@ class Test:
y = extracted()
return y
- def extracted() -> Any:
+ def extracted() -> int | Any:
y = x * 2
return y
diff --git a/python/testData/refactoring/extractmethod/MethodInnerFuncWithOwnParam.after.withTypes.py b/python/testData/refactoring/extractmethod/MethodInnerFuncWithOwnParam.after.withTypes.py
index c2e02fbb70f0..0d5bc82bd5e0 100644
--- a/python/testData/refactoring/extractmethod/MethodInnerFuncWithOwnParam.after.withTypes.py
+++ b/python/testData/refactoring/extractmethod/MethodInnerFuncWithOwnParam.after.withTypes.py
@@ -7,6 +7,6 @@ class Test:
y = extracted(x)
return y
- def extracted(x_new) -> Any:
+ def extracted(x_new) -> int | Any:
y = x_new * 2
return y
diff --git a/python/testData/refactoring/extractmethod/SimilarBinaryExpressions.after.withTypes.py b/python/testData/refactoring/extractmethod/SimilarBinaryExpressions.after.withTypes.py
index e0b9bbee2fb4..77297a6fc0ef 100644
--- a/python/testData/refactoring/extractmethod/SimilarBinaryExpressions.after.withTypes.py
+++ b/python/testData/refactoring/extractmethod/SimilarBinaryExpressions.after.withTypes.py
@@ -6,5 +6,5 @@ def compound_duplicate(p1, p2):
print(bar(p2))
-def bar(p1_new) -> Any:
+def bar(p1_new) -> int | Any:
return p1_new + 1
\ No newline at end of file
diff --git a/python/testData/refactoring/extractmethod/TypedStatements.after.withTypes.py b/python/testData/refactoring/extractmethod/TypedStatements.after.withTypes.py
index d3b48818b4c6..5794bdc17894 100644
--- a/python/testData/refactoring/extractmethod/TypedStatements.after.withTypes.py
+++ b/python/testData/refactoring/extractmethod/TypedStatements.after.withTypes.py
@@ -14,6 +14,6 @@ def f(p: Person, salutation: str, ageHolder: Ageholder):
return greeting(ageHolder, p, salutation)
-def greeting(ageHolder_new: Ageholder, p_new: Person, salutation_new: str) -> str:
+def greeting(ageHolder_new: Ageholder, p_new: Person, salutation_new: str) -> LiteralString | str | int:
return salutation_new + p_new.name + "(" + ageHolder_new.age + ")"
diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java
index 4122c35dcda9..9a299c7d88ea 100644
--- a/python/testSrc/com/jetbrains/python/PyTypeTest.java
+++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java
@@ -797,11 +797,11 @@ public class PyTypeTest extends PyTestCase {
""";
final PyExpression expr = parseExpr(text);
assertNotNull(expr);
- doTest("UnsafeUnion[Union[int, str], Any]", expr, TypeEvalContext.codeCompletion(expr.getProject(), expr.getContainingFile()));
+ doTest("Union[Union[int, str], Any]", expr, TypeEvalContext.codeCompletion(expr.getProject(), expr.getContainingFile()));
}
public void testUpperBoundGeneric() {
- doTest("UnsafeUnion[Union[int, str], Any]",
+ doTest("Union[Union[int, str], Any]",
"""
def foo(x):
'''
@@ -1641,7 +1641,7 @@ public class PyTypeTest extends PyTestCase {
doTest("List[Union[str, int]]", "expr = ['1', 1, 1]");
- doTest("List[UnsafeUnion[Union[str, int], Any]]", "expr = ['1', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]");
+ doTest("List[Union[Union[str, int], Any]]", "expr = ['1', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]");
}
public void testSetLiteral() {
@@ -1649,7 +1649,7 @@ public class PyTypeTest extends PyTestCase {
doTest("Set[Union[str, int]]", "expr = {'1', 1, 1}");
- doTest("Set[UnsafeUnion[Union[str, int], Any]]", "expr = {'1', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}");
+ doTest("Set[Union[Union[str, int], Any]]", "expr = {'1', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}");
}
public void testDictLiteral() {
@@ -2773,23 +2773,23 @@ public class PyTypeTest extends PyTestCase {
runWithLanguageLevel(
LanguageLevel.PYTHON35,
() -> {
- doTest("UnsafeUnion[int, Any]",
+ doTest("Union[int, Any]",
"""
from typing import Any
x: Any
expr = x * 2""");
- doTest("UnsafeUnion[int, Any]",
+ doTest("Union[int, Any]",
"""
from typing import Any
x: Any
expr = 2 * x""");
- doTest("UnsafeUnion[int, Any]",
+ doTest("Union[int, Any]",
"def f(x):\n" +
" expr = x * 2");
- doTest("UnsafeUnion[int, Any]",
+ doTest("Union[int, Any]",
"def f(x):\n" +
" expr = 2 * x");
}
diff --git a/python/testSrc/com/jetbrains/python/PyTypingTest.java b/python/testSrc/com/jetbrains/python/PyTypingTest.java
index c22891e240dc..d5cf4724ce90 100644
--- a/python/testSrc/com/jetbrains/python/PyTypingTest.java
+++ b/python/testSrc/com/jetbrains/python/PyTypingTest.java
@@ -18,7 +18,6 @@ package com.jetbrains.python;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.util.PsiTreeUtil;
@@ -248,7 +247,7 @@ public class PyTypingTest extends PyTestCase {
}
public void testAnyStrForUnknown() {
- doTest("UnsafeUnion[str | bytes, Any]",
+ doTest("str | bytes | Any",
"""
from typing import AnyStr
@@ -3614,52 +3613,6 @@ public class PyTypingTest extends PyTestCase {
expr = receiver.get()""");
}
- // PY-24834
- // It works incorrectly due to PY-83119 (the information about unresolved union member attributes
- // being lost during type inference).
- public void testGenericUnionMemberMethodCallSomeMembersDoNotOwnIt() {
- doTest("str", // Should be `str | Any`
- """
- class Box[T]:
- def get(self) -> T:
- pass
- r: int | Box[str] = ...
- expr = r.get()
- """);
- }
-
- // PY-24834
- // This version doesn't work now properly because of lacking constraint solving.
- // We can't match `Box[T]` for `self` with `Box[int] | Box[str]`.
- public void testGenericUnionMemberCallAllMembersAreSameClassParameterizations() {
- doTest("Any", // Should be `int | str`
- """
- class Box[T]:
- def get(self) -> T:
- pass
-
- r: Box[int] | Box[str] = ...
- expr = r.get()
- """);
- }
-
- // PY-24834
- public void testGenericUnionMemberCallAllMembersOwnIt() {
- doTest("int | str",
- """
- class Box1[T]:
- def get(self) -> T:
- pass
-
- class Box2[T]:
- def get(self) -> T:
- pass
-
- r: Box1[int] | Box2[str] = ...
- expr = r.get()
- """);
- }
-
public void testGenericClassTypeHintedInDocstrings() {
doTest("int",
"""
@@ -6784,26 +6737,6 @@ public class PyTypingTest extends PyTestCase {
""");
}
- // See com.jetbrains.python.refactoring.PyExtractMethodTest.testTypedStatements
- //
- // This scenario changes depending on whether the strict unions are enabled.
- // Without them, the inferred type is LiteralString | str | int, because due to special handling
- // of unions containing literal types in PyTypeChecker, none of the candidate methods fully matches:
- // `LiteralString | str | int` receiver is compatible with neither `LiteralString`, `str` nor `int` for `self`,
- // so we infer a union of all possible return types.
- // With strict unions, due to special handling of self in #processSelfParameter, only
- // `__add__(self: str, other: str) -> str` overload remains.
- // PY-24834 PY-83313
- public void testUnionStrConcat() {
- //Registry.get("python.typing.strict.unions").setValue(false, myFixture.getTestRootDisposable());
- doTest("str", """
- from typing import LiteralString
-
- x: LiteralString | str | int
- expr = x + "foo"
- """);
- }
-
private void doTestNoInjectedText(@NotNull String text) {
myFixture.configureByText(PythonFileType.INSTANCE, text);
final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject());
diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java
index 43322f7cfa89..b5fb4d624923 100644
--- a/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java
@@ -2895,28 +2895,6 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
""");
}
- // PY-74277
- public void testPassingTypeIsCallable() {
- runWithLanguageLevel(
- LanguageLevel.PYTHON312,
- () -> doTestByText("""
- from typing_extensions import TypeIs, Callable
-
- def takes_narrower(x: int | str, narrower: Callable[[object], TypeIs[int]]):
- if narrower(x):
- expr1: int = x
- # └─ should be of `int` type
- else:
- expr2: str = x
- # └─ should be of `str` type
-
- def is_bool(x: object) -> TypeIs[bool]:
- return isinstance(x, bool)
-
- takes_narrower(42, is_bool)
- """));
- }
-
// PY-75556
public void testLiteralTypeOnKwargs() {
doTestByText("""
@@ -3095,11 +3073,6 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
""");
}
- // PY-24834
- public void testStrictUnionImplicitProtocolMatching() {
- doTest();
- }
-
// PY-76822
public void testProtocolWithAssignedPropertyInMethod() {
doTestByText("""
diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
index b8763ba05f4f..30852b77ed32 100644
--- a/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
@@ -477,21 +477,6 @@ public class Py3UnresolvedReferencesInspectionTest extends PyInspectionTestCase
}
- // PY-24834
- public void testStrictUnionMemberAttributeAccess() {
- doTest();
- }
-
- // PY-24834
- public void testStrictUnionMemberOperatorAccess() {
- doTest();
- }
-
- // PY-24834
- public void testStrictUnionMemberExtendingAny() {
- doTest();
- }
-
// PY-83529
public void testPackageAttributeInPresenceOfBinarySkeleton() {
runWithAdditionalClassEntryInSdkRoots(getTestDirectoryPath() + "/site-packages", () -> {
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java
index 82313f268d30..d64e011b3850 100644
--- a/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/PyTypeCheckerInspectionTest.java
@@ -1534,10 +1534,10 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
title: str
year: int
- movies1: list[Movie] = [
+ movies1: list[Movie] = [
{"title": "Blade Runner", "year": 1982}, # OK
{"title": "The Matrix"},
- ]
+ ]
movies2: list[Movie] = [
{"title": "The Matrix"},
]
@@ -1609,6 +1609,29 @@ public class PyTypeCheckerInspectionTest extends PyInspectionTestCase {
);
}
+ // PY-74277
+ public void testPassingTypeIsCallable() {
+ runWithLanguageLevel(
+ LanguageLevel.PYTHON312,
+ () -> doTestByText("""
+ from typing_extensions import TypeIs
+
+ def takes_narrower(x: int | str, narrower: Callable[[object], TypeIs[int]]):
+ if narrower(x):
+ expr1: int = x
+ # └─ should be of `int` type
+ else:
+ expr2: str = x
+ # └─ should be of `str` type
+
+ def is_bool(x: object) -> TypeIs[bool]:
+ return isinstance(x, bool)
+
+ takes_narrower(42, is_bool)
+ """));
+ }
+
+
public void testGeneratorTypeHint() {
runWithLanguageLevel(LanguageLevel.getLatest(), this::doTest);
}
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnusedImportTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnusedImportTest.java
index 954d30322139..f5ed7bec79b9 100644
--- a/python/testSrc/com/jetbrains/python/inspections/PyUnusedImportTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/PyUnusedImportTest.java
@@ -106,7 +106,7 @@ public class PyUnusedImportTest extends PyTestCase {
myFixture.copyDirectoryToProject(getTestName(true), "");
myFixture.configureFromTempProjectFile(filename);
myFixture.enableInspections(PyUnusedImportsInspection.class, PyUnresolvedReferencesInspection.class);
- myFixture.checkHighlighting(true, false, true);
+ myFixture.checkHighlighting(true, false, false);
}
@Override