diff --git a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java index e6884c84d402..0f24a0e69837 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java @@ -811,7 +811,8 @@ public class PyFunctionImpl extends PyBaseElementImpl implements .skipWhile(siblingStub -> !stub.equals(siblingStub)) .transform(nextSiblingStub -> as(nextSiblingStub, PyTargetExpressionStub.class)) .filter(Objects::nonNull) - .filter(nextSiblingStub -> nextSiblingStub.getInitializerType() == PyTargetExpressionStub.InitializerType.CallExpression) + .filter(nextSiblingStub -> nextSiblingStub.getInitializerType() == PyTargetExpressionStub.InitializerType.CallExpression && + Objects.equals(stub.getName(), nextSiblingStub.getName())) .transform(PyTargetExpressionStub::getInitializer) .transform( initializerName -> { diff --git a/python/testData/inspections/PyArgumentListInspection/AnotherMethodIsWrappedIntoStatic/a.py b/python/testData/inspections/PyArgumentListInspection/AnotherMethodIsWrappedIntoStatic/a.py new file mode 100644 index 000000000000..3bed35c16015 --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/AnotherMethodIsWrappedIntoStatic/a.py @@ -0,0 +1,3 @@ +from b import A + +A().my_method(10) \ No newline at end of file diff --git a/python/testData/inspections/PyArgumentListInspection/AnotherMethodIsWrappedIntoStatic/b.py b/python/testData/inspections/PyArgumentListInspection/AnotherMethodIsWrappedIntoStatic/b.py new file mode 100644 index 000000000000..4f6dad712c51 --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/AnotherMethodIsWrappedIntoStatic/b.py @@ -0,0 +1,8 @@ +class A: + def my_method(self, p): + pass + + def one_more(p): + pass + + one_more = staticmethod(one_more) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java index eaa229b5ef14..2ba9a853e628 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java @@ -366,4 +366,9 @@ public class PyArgumentListInspectionTest extends PyInspectionTestCase { public void testInitializingTypeVar() { doTest(); } + + // PY-30182 + public void testAnotherMethodIsWrappedIntoStatic() { + doMultiFileTest(); + } }