PY-80248 Fix: Reference to type alias statement reported as invalid type hint

GitOrigin-RevId: 72c3631559622e278a23fa9d827ceef1667001cb
This commit is contained in:
Daniil Kalinin
2025-04-08 22:17:42 +02:00
committed by intellij-monorepo-bot
parent 6872f28d2e
commit aa84f6f92d
2 changed files with 10 additions and 1 deletions

View File

@@ -1553,7 +1553,7 @@ class PyTypeHintsInspection : PyInspection() {
return type is PyTypingNewType || type is PyTypedDictType
}
}
is PyTypeParameter, is PyClass -> true
is PyTypeParameter, is PyClass, is PyTypeAliasStatement -> true
is PyFunction -> resolvedElement.qualifiedName?.let {
it.endsWith("ParamSpec.args") || it.endsWith("ParamSpec.kwargs")
} == true

View File

@@ -2563,6 +2563,15 @@ public class PyTypeHintsInspectionTest extends PyInspectionTestCase {
""");
}
// PY-80248
public void testReferenceToTypeStatementIsValidTypeHint() {
doTestByText("""
type my_type = str
def func1(x: my_type) -> str: ...
""");
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {