diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java index 825366c1b03c..dda16379da98 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyConvertMethodToPropertyIntention.java @@ -49,8 +49,10 @@ public class PyConvertMethodToPropertyIntention extends BaseIntentionAction { function.accept(new PyRecursiveElementVisitor() { @Override public void visitPyReturnStatement(PyReturnStatement node) { - available[0] = true; + if (node.getExpression() != null) + available[0] = true; } + }); return available[0]; diff --git a/python/testData/intentions/PyConvertMethodToPropertyIntentionTest/emptyReturn.py b/python/testData/intentions/PyConvertMethodToPropertyIntentionTest/emptyReturn.py new file mode 100644 index 000000000000..ef5434161170 --- /dev/null +++ b/python/testData/intentions/PyConvertMethodToPropertyIntentionTest/emptyReturn.py @@ -0,0 +1,3 @@ +class A(): + def moo(self): + return \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/intentions/PyConvertMethodToPropertyIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyConvertMethodToPropertyIntentionTest.java index f1b9c5bf2362..772a54b6163b 100644 --- a/python/testSrc/com/jetbrains/python/intentions/PyConvertMethodToPropertyIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/intentions/PyConvertMethodToPropertyIntentionTest.java @@ -23,6 +23,10 @@ public class PyConvertMethodToPropertyIntentionTest extends PyIntentionTestCase doNegateIntentionTest(PyBundle.message("INTN.convert.method.to.property")); } + public void testEmptyReturn() throws Exception { + doNegateIntentionTest(PyBundle.message("INTN.convert.method.to.property")); + } + public void testNoReturn() throws Exception { doNegateIntentionTest(PyBundle.message("INTN.convert.method.to.property")); }