dadadel / pyment

Format and convert Python docstrings and generates patches
GNU General Public License v3.0
905 stars 62 forks source link

Type is removed from parameter if not in type hints when converting reST docstring #99

Closed dadadel closed 3 years ago

dadadel commented 3 years ago

If a type is provided in a reST dosctring for a parameter, it will be removed in the output docstring if not present in the type hint:

def func(param1):
    """Description

    :param param1:
    :type param1: str
    :returns: the return value

    """
    pass

Will produce:

# Patch generated by Pyment v0.4.0dev

--- a/t.py
+++ b/t.py
@@ -1,8 +1,7 @@
 def func(param1):
     """Description

-    :param param1:
-    :type param1: str
+    :param param1: 
     :returns: the return value

     """

However it works well when input docstring is google style:

def func(param1):
    """Description

    Args:
      param1(str):

    Returns:
      the return value

    """
    pass

Produces:

# Patch generated by Pyment v0.4.0dev

--- a/t2.py
+++ b/t2.py
@@ -1,11 +1,9 @@
 def func(param1):
     """Description

-    Args:
-      param1(str):
-
-    Returns:
-      the return value
+    :param param1: 
+    :type param1: str
+    :returns: the return value

     """
     pass