From 0f8e5afa8a6655ba4aa6f24f0d41161074bb92db Mon Sep 17 00:00:00 2001 From: Andrey Vokin Date: Thu, 15 Aug 2024 11:29:06 +0200 Subject: [PATCH] PY-73263 Python 3.13 Support - Code Insight - Typeshed Remove custom deprecation check for abc. Typesheds now have deprecation decorator GitOrigin-RevId: 72ba0028bfda2d7eda4a8e01aed5962613305531 --- .../inspections/PyDeprecationInspection.java | 39 ------------------- .../deprecation/abcDeprecatedAbstracts.py | 16 ++++---- 2 files changed, 8 insertions(+), 47 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyDeprecationInspection.java b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyDeprecationInspection.java index f3483532cbcd..ffee629825a0 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyDeprecationInspection.java +++ b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyDeprecationInspection.java @@ -93,45 +93,6 @@ public final class PyDeprecationInspection extends PyInspection { } } - @Override - public void visitPyFunction(@NotNull PyFunction node) { - super.visitPyFunction(node); - - final PyDecoratorList decoratorList = node.getDecoratorList(); - if (!LanguageLevel.forElement(node).isPython2() && decoratorList != null) { - for (PyDecorator decorator : decoratorList.getDecorators()) { - for (KnownDecorator knownDecorator : PyKnownDecoratorUtil.asKnownDecorators(decorator, myTypeEvalContext)) { - final KnownDecorator deprecated; - final KnownDecorator builtin; - - if (knownDecorator == KnownDecorator.ABC_ABSTRACTPROPERTY) { - deprecated = KnownDecorator.ABC_ABSTRACTPROPERTY; - builtin = KnownDecorator.PROPERTY; - } - else if (knownDecorator == KnownDecorator.ABC_ABSTRACTCLASSMETHOD) { - deprecated = KnownDecorator.ABC_ABSTRACTCLASSMETHOD; - builtin = KnownDecorator.CLASSMETHOD; - } - else if (knownDecorator == KnownDecorator.ABC_ABSTRACTSTATICMETHOD) { - deprecated = KnownDecorator.ABC_ABSTRACTSTATICMETHOD; - builtin = KnownDecorator.STATICMETHOD; - } - else { - continue; - } - - final KnownDecorator abcAbsMethod = KnownDecorator.ABC_ABSTRACTMETHOD; - final String message = PyPsiBundle.message("INSP.deprecation.abc.decorator.deprecated.use.alternative", - deprecated.getQualifiedName(), - builtin.getQualifiedName(), - abcAbsMethod.getQualifiedName()); - - registerProblem(decorator, message, ProblemHighlightType.LIKE_DEPRECATED); - } - } - } - } - @Nullable private PyElement resolve(@NotNull PyReferenceExpression node) { final PyElement resolve = PyUtil.as(node.getReference(getResolveContext()).resolve(), PyElement.class); diff --git a/python/testData/deprecation/abcDeprecatedAbstracts.py b/python/testData/deprecation/abcDeprecatedAbstracts.py index 81b5af0d51f6..7047ca1cfd99 100644 --- a/python/testData/deprecation/abcDeprecatedAbstracts.py +++ b/python/testData/deprecation/abcDeprecatedAbstracts.py @@ -2,25 +2,25 @@ import abc class A(metaclass=abc.ABCMeta): - @abc.abstractproperty + @abc.abstractproperty def prop(self): pass -from abc import abstractproperty +from abc import abstractproperty class B(metaclass=abc.ABCMeta): - @abstractproperty + @abstractproperty def prop(self): pass -from abc import abstractproperty as ap +from abc import abstractproperty as ap class C(metaclass=abc.ABCMeta): - @ap + @ap def prop(self): pass @@ -29,16 +29,16 @@ import abc as foo class D(metaclass=abc.ABCMeta): - @foo.abstractproperty + @foo.abstractproperty def prop(self): pass class A: - @abc.abstractclassmethod + @abc.abstractclassmethod def foo(cls): pass - @abc.abstractstaticmethod + @abc.abstractstaticmethod def bar(): pass \ No newline at end of file