PY-62301 Not highlight Self in __new__ method

GitOrigin-RevId: 099d4ca6f34b30e757ad030f418c9db827a71abe
This commit is contained in:
Andrey.Matveev
2024-06-17 17:22:42 +03:00
committed by intellij-monorepo-bot
parent c15b293135
commit 2854de57c0
2 changed files with 11 additions and 1 deletions

View File

@@ -219,7 +219,7 @@ class PyTypeHintsInspection : PyInspection() {
val functionParent = PsiTreeUtil.getParentOfType(node, PyFunction::class.java)
if (functionParent != null) {
if (PyAstFunction.Modifier.STATICMETHOD == functionParent.modifier) {
if (PyAstFunction.Modifier.STATICMETHOD == functionParent.modifier && PyNames.NEW != functionParent.name) {
registerProblemForSelves(PyPsiBundle.message("INSP.type.hints.self.use.in.staticmethod"))
}

View File

@@ -1314,6 +1314,16 @@ public class PyTypeHintsInspectionTest extends PyInspectionTestCase {
""");
}
// PY-62301
public void testTypingSelfInNewMethod() {
doTestByText("""
from typing import Self
class ReturnsSelf:
def __new__(cls, value: int) -> Self: ...
""");
}
// PY-36317
public void testDictSubscriptionNotReportedAsParametrizedGeneric() {
doTestByText("""