From 752b7b562f0a9ac23ff5e0afcc1769b0290c3dcb Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 29 Aug 2011 14:18:23 +0200 Subject: [PATCH] first parameter of @classmethod method is callable --- .../python/inspections/PyCallingNonCallableInspection.java | 3 +++ .../PyCallingNonCallableInspection/classMethodFirstParam.py | 4 ++++ .../python/inspections/PyCallingNonCallableTest.java | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 python/testData/inspections/PyCallingNonCallableInspection/classMethodFirstParam.py diff --git a/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java b/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java index c045b17c53a2..1f8384cb8517 100644 --- a/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyCallingNonCallableInspection.java @@ -52,6 +52,9 @@ public class PyCallingNonCallableInspection extends PyInspection { PyType calleeType = myTypeEvalContext.getType(callee); if (calleeType instanceof PyClassType) { PyClassType classType = (PyClassType) calleeType; + if (classType.isDefinition()) { + return; + } PyClass cls = classType.getPyClass(); if (isMethodType(node, classType)) { return; diff --git a/python/testData/inspections/PyCallingNonCallableInspection/classMethodFirstParam.py b/python/testData/inspections/PyCallingNonCallableInspection/classMethodFirstParam.py new file mode 100644 index 000000000000..ff7cb9aa8c4b --- /dev/null +++ b/python/testData/inspections/PyCallingNonCallableInspection/classMethodFirstParam.py @@ -0,0 +1,4 @@ +class C: + @classmethod + def foo(cls): + return cls() diff --git a/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java b/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java index 3d656581bbfc..82589bf2c88d 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyCallingNonCallableTest.java @@ -35,6 +35,10 @@ public class PyCallingNonCallableTest extends PyLightFixtureTestCase { doTest(); } + public void testClassMethodFirstParam() { + doTest(); + } + private void doTest() { setLanguageLevel(LanguageLevel.PYTHON27); try {