From afb33f77e8386ca87a8508bc991a5ed2a6e31e05 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 15 Sep 2015 12:18:31 +0300 Subject: [PATCH] Don't use "object" as fallback return type in Google and Numpy docstrings Because it breaks code insight otherwise. Type "object" is not the same thing as "Any", and the latter isn't fully supported in PyCharm yet. As a temporary solution insert empty line under "Returns" section instead. --- .../python/documentation/docstrings/PyDocstringGenerator.java | 4 ++-- python/testData/intentions/afterGoogleDocStubWithTypes.py | 2 +- python/testData/intentions/afterNumpyDocStubWithTypes.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/documentation/docstrings/PyDocstringGenerator.java b/python/src/com/jetbrains/python/documentation/docstrings/PyDocstringGenerator.java index 247d8ebf731a..9f32cd3091ca 100644 --- a/python/src/com/jetbrains/python/documentation/docstrings/PyDocstringGenerator.java +++ b/python/src/com/jetbrains/python/documentation/docstrings/PyDocstringGenerator.java @@ -441,8 +441,8 @@ public class PyDocstringGenerator { sectionBuilder.startReturnsSection(); boolean hasTypedReturns = false; for (DocstringParam returnValue : returnValues) { - if (returnValue.getType() != null) { - sectionBuilder.addReturnValue(null, getDefaultType(returnValue), ""); + if (StringUtil.isNotEmpty(returnValue.getType())) { + sectionBuilder.addReturnValue(null, returnValue.getType(), ""); hasTypedReturns = true; } } diff --git a/python/testData/intentions/afterGoogleDocStubWithTypes.py b/python/testData/intentions/afterGoogleDocStubWithTypes.py index c961ab9ef68a..d98dffbfa73b 100644 --- a/python/testData/intentions/afterGoogleDocStubWithTypes.py +++ b/python/testData/intentions/afterGoogleDocStubWithTypes.py @@ -6,6 +6,6 @@ def f(x, y): y (): Returns: - object: + """ return 42 \ No newline at end of file diff --git a/python/testData/intentions/afterNumpyDocStubWithTypes.py b/python/testData/intentions/afterNumpyDocStubWithTypes.py index 025c246fed0e..1b9e2fcb6763 100644 --- a/python/testData/intentions/afterNumpyDocStubWithTypes.py +++ b/python/testData/intentions/afterNumpyDocStubWithTypes.py @@ -8,6 +8,6 @@ def f(x, y): Returns ------- - object + """ return 42 \ No newline at end of file