mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix highlighting method that overrides final method without qualified name (PEP 591) (PY-34945)
GitOrigin-RevId: c7f0b0fdb0472850bfdd6d768fbad3a935cc3e6a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
88995dba66
commit
5f2630859c
@@ -67,9 +67,12 @@ class PyFinalInspection : PyInspection() {
|
||||
if (cls != null) {
|
||||
PySuperMethodsSearch
|
||||
.search(node, myTypeEvalContext)
|
||||
.firstOrNull { it is PyFunction && isFinal(it) }
|
||||
.asSequence()
|
||||
.filterIsInstance<PyFunction>()
|
||||
.firstOrNull { isFinal(it) }
|
||||
?.let {
|
||||
registerProblem(node.nameIdentifier, "'${(it as PyFunction).qualifiedName}' is marked as '@final' and should not be overridden")
|
||||
val qualifiedName = it.qualifiedName ?: it.containingClass?.name + "." + it.name
|
||||
registerProblem(node.nameIdentifier, "'$qualifiedName' is marked as '@final' and should not be overridden")
|
||||
}
|
||||
|
||||
if (!PyiUtil.isInsideStub(node)) {
|
||||
|
||||
@@ -59,6 +59,21 @@ public class PyFinalInspectionTest extends PyInspectionTestCase {
|
||||
" pass");
|
||||
}
|
||||
|
||||
// PY-34945
|
||||
public void testOverridingFinalMethodWithoutQualifiedName() {
|
||||
doTestByText("from typing_extensions import final\n" +
|
||||
"def output():\n" +
|
||||
" class Output:\n" +
|
||||
" @final\n" +
|
||||
" def foo(self):\n" +
|
||||
" pass\n" +
|
||||
" return Output\n" +
|
||||
"r = output()\n" +
|
||||
"class SubClass(r):\n" +
|
||||
" def <warning descr=\"'Output.foo' is marked as '@final' and should not be overridden\">foo</warning>(self):\n" +
|
||||
" pass");
|
||||
}
|
||||
|
||||
// PY-34945
|
||||
public void testOverridingOverloadedFinalMethod() {
|
||||
doMultiFileTest();
|
||||
|
||||
Reference in New Issue
Block a user