diff --git a/python/src/com/jetbrains/python/documentation/docstrings/GoogleCodeStyleDocString.java b/python/src/com/jetbrains/python/documentation/docstrings/GoogleCodeStyleDocString.java index 1cb57a177cd0..f2c9b50e01dd 100644 --- a/python/src/com/jetbrains/python/documentation/docstrings/GoogleCodeStyleDocString.java +++ b/python/src/com/jetbrains/python/documentation/docstrings/GoogleCodeStyleDocString.java @@ -31,7 +31,7 @@ import java.util.regex.Pattern; */ public class GoogleCodeStyleDocString extends SectionBasedDocString { public static final Pattern SECTION_HEADER = Pattern.compile("^[ \t]*([\\w \t]+):[ \t]*$", Pattern.MULTILINE); - private static final Pattern FIELD_NAME_AND_TYPE = Pattern.compile("^[ \t]*(.+?)[ \t]*\\([ \t]*(.*?)[ \t]*\\)[ \t]*$", Pattern.MULTILINE); + private static final Pattern FIELD_NAME_AND_TYPE = Pattern.compile("^[ \t]*(.+?)[ \t]*\\([ \t]*(.*?)[ \t]*\\)?[ \t]*$", Pattern.MULTILINE); public GoogleCodeStyleDocString(@NotNull Substring text) { super(text); diff --git a/python/testData/completion/paramTypeInGoogleDocstringWithoutClosingParenthesis.py b/python/testData/completion/paramTypeInGoogleDocstringWithoutClosingParenthesis.py new file mode 100644 index 000000000000..721ff95fb739 --- /dev/null +++ b/python/testData/completion/paramTypeInGoogleDocstringWithoutClosingParenthesis.py @@ -0,0 +1,5 @@ +def f(): + """ + Args: + x (str + """ \ No newline at end of file diff --git a/python/testData/docstrings/googleNoClosingParenthesisAfterParamType.py b/python/testData/docstrings/googleNoClosingParenthesisAfterParamType.py new file mode 100644 index 000000000000..b3bc9655cec3 --- /dev/null +++ b/python/testData/docstrings/googleNoClosingParenthesisAfterParamType.py @@ -0,0 +1,6 @@ +def f(x, y): + """ + Args: + x (Foo + y (Bar : description + """ \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PySectionBasedDocStringTest.java b/python/testSrc/com/jetbrains/python/PySectionBasedDocStringTest.java index 9488be14829e..166da2926731 100644 --- a/python/testSrc/com/jetbrains/python/PySectionBasedDocStringTest.java +++ b/python/testSrc/com/jetbrains/python/PySectionBasedDocStringTest.java @@ -378,6 +378,16 @@ public class PySectionBasedDocStringTest extends PyTestCase { "second line", firstExample.getDescription()); } + // PY-17002 + public void testGoogleNoClosingParenthesisAfterParamType() { + final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString(); + assertSize(1, docString.getSections()); + final List params = docString.getSections().get(0).getFields(); + assertSize(2, params); + assertEquals("Foo", params.get(0).getType()); + assertEquals("Bar", params.get(1).getType()); + } + @Override protected String getTestDataPath() { return super.getTestDataPath() + "/docstrings"; diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java index ad48594360a6..4e00465d167a 100644 --- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java +++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java @@ -484,6 +484,18 @@ public class PythonCompletionTest extends PyTestCase { }); } + // PY-17002 + public void testParamTypeInGoogleDocstringWithoutClosingParenthesis() { + runWithDocStringFormat(DocStringFormat.GOOGLE, new Runnable() { + @Override + public void run() { + final List variants = doTestByFile(); + assertNotNull(variants); + assertSameElements(variants, "str", "basestring"); + } + }); + } + public void testPep328Completion() { // PY-3409 myFixture.copyDirectoryToProject("pep328", "pep328"); myFixture.configureByFile("pep328/package/subpackage1/moduleX.py");