PY-80729 "Inspect Project" gets stuck analyzing the project

Disable python.use.better.control.flow.type.inference for now


Merge-request: IJ-MR-161520
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 98ceafd932e6382847e49dc550c7e9b76c6626b9
This commit is contained in:
Aleksandr.Govenko
2025-04-29 10:30:12 +00:00
committed by intellij-monorepo-bot
parent 7e639b65b7
commit 4a5de0cccc
2 changed files with 73 additions and 72 deletions

View File

@@ -464,7 +464,7 @@
<categoryKey>INTN.category.python</categoryKey>
</intentionAction>
<registryKey defaultValue="true"
<registryKey defaultValue="false"
description="Enable experimental better handling of recursive cases in type inference"
key="python.use.better.control.flow.type.inference"/>
<registryKey defaultValue="true"

View File

@@ -9,6 +9,7 @@ import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.types.*;
import com.jetbrains.python.psi.types.PyTypeChecker.GenericSubstitutions;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -104,77 +105,77 @@ public class Py3TypeTest extends PyTestCase {
""");
}
// PY-76659
public void testRecursiveResolve() {
doTest("int",
"""
x = 42
while x:
x = x + 1
expr = x""");
}
// PY-76659
public void testRecursiveResolve2() {
doTest("int",
"""
x = 42
b: bool = ...
while x:
if b:
x = x + 1
expr = x
else:
x = x - 1
""");
}
// PY-76659
public void testDeclareAfterUse() {
doTest("int | Any",
"""
from typing import Any, TypeGuard
def is_positive_integer(value: Any) -> TypeGuard[int]:
return isinstance(value, int) and value > 0
def bar() -> object:
return 321
def foo():
for i in range(1, 100):
if i > 1:
expr = x
x = bar()
if not is_positive_integer(x):
break
""");
}
// PY-76659
public void testClassChain() {
doTest("B | C | D | A",
"""
class A:
def bar() -> "B":
return B()
class B:
def bar() -> "C":
return C()
class C:
def bar() -> "D":
return D()
class D:
def bar() -> A:
return A()
def foo(b):
x = A()
while b:
x = x.bar()
expr = x""");
}
//// PY-76659
//public void testRecursiveResolve() {
// doTest("int",
// """
// x = 42
// while x:
// x = x + 1
// expr = x""");
//}
//
//// PY-76659
//public void testRecursiveResolve2() {
// doTest("int",
// """
// x = 42
// b: bool = ...
// while x:
// if b:
// x = x + 1
// expr = x
// else:
// x = x - 1
// """);
//}
//
//// PY-76659
//public void testDeclareAfterUse() {
// doTest("int | Any",
// """
// from typing import Any, TypeGuard
//
// def is_positive_integer(value: Any) -> TypeGuard[int]:
// return isinstance(value, int) and value > 0
//
// def bar() -> object:
// return 321
//
// def foo():
// for i in range(1, 100):
// if i > 1:
// expr = x
// x = bar()
// if not is_positive_integer(x):
// break
// """);
//}
//
//// PY-76659
//public void testClassChain() {
// doTest("B | C | D | A",
// """
// class A:
// def bar() -> "B":
// return B()
// class B:
// def bar() -> "C":
// return C()
// class C:
// def bar() -> "D":
// return D()
// class D:
// def bar() -> A:
// return A()
//
// def foo(b):
// x = A()
// while b:
// x = x.bar()
//
// expr = x""");
//}
// PY-6702
public void testYieldFromType() {