diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java index 54a20eeceb26..3b2b9a71442f 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java @@ -49,9 +49,8 @@ public class SpecifyTypeInDocstringIntention implements IntentionAction { } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - PsiElement elementAt = file.findElementAt(editor.getCaretModel().getOffset() - 1); - if (elementAt != null && elementAt.getNode() != null && !(elementAt.getNode().getElementType() == PyTokenTypes.IDENTIFIER)) - elementAt = file.findElementAt(editor.getCaretModel().getOffset()); + myText = PyBundle.message("INTN.specify.type"); + PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyCallExpression callExpression = PsiTreeUtil.getParentOfType(elementAt, PyCallExpression.class); if (callExpression != null && callExpression.resolveCalleeFunction(PyResolveContext.defaultContext()) != null) { diff --git a/python/testData/intentions/afterTypeInPy3Annotation.py b/python/testData/intentions/afterTypeInPy3Annotation.py index 53a85344911b..3dca05f293e4 100644 --- a/python/testData/intentions/afterTypeInPy3Annotation.py +++ b/python/testData/intentions/afterTypeInPy3Annotation.py @@ -1,3 +1,3 @@ -def foo(a: object, b): +def foo(a : object, b): a. b = 1 \ No newline at end of file