Don't use "object" as fallback return type in Google and Numpy docstrings
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Tue, 15 Sep 2015 09:18:31 +0000 (12:18 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Tue, 15 Sep 2015 09:18:31 +0000 (12:18 +0300)
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/src/com/jetbrains/python/documentation/docstrings/PyDocstringGenerator.java
python/testData/intentions/afterGoogleDocStubWithTypes.py
python/testData/intentions/afterNumpyDocStubWithTypes.py

index 247d8ebf731a73e106e3b37fd2e4b60a67bb9ca6..9f32cd3091ca692474ac8f90af62e460e6233096 100644 (file)
@@ -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;
           }
         }
index c961ab9ef68ac1c9f3657fe222ed4c25a3e3f6b7..d98dffbfa73b9d170de2a4f446c4ad60877e70bf 100644 (file)
@@ -6,6 +6,6 @@ def f(x, y):
       y ():
 
     Returns:
-      object:
+
     """
     return 42
\ No newline at end of file
index 025c246fed0ef4a65a8ff4faf865bde4efe57b02..1b9e2fcb67637ceefc6f7481b7bcc4fca265d726 100644 (file)
@@ -8,6 +8,6 @@ def f(x, y):
 
     Returns
     -------
-    object
+
     """
     return 42
\ No newline at end of file