dadadel / pyment

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

list, tuple, dict default param values are not parsed correctly #46

Closed dadadel closed 3 years ago

dadadel commented 7 years ago

When a function has parameters with default values that are list, dictionary or tuple, Pyment will just consider several parameters splitting on coma.

The following python code:

def func1(param1=[1, None, "hehe"]):
    pass

def func2(param1=(1, None, "hehe")):
    pass

def func3(param1={0: 1, "a": None}):
    pass

Will produce the patch:

# Patch generated by Pyment v0.3.2-dev4

--- a/issue46.py
+++ b/issue46.py
@@ -1,9 +1,29 @@
 def func1(param1=[1, None, "hehe"]):
+    """
+
+    :param param1:  (Default value = [1)
+    :param None: 
+    :param "hehe"]: 
+
+    """
     pass

 def func2(param1=(1, None, "hehe")):
+    """
+
+    :param param1:  (Default value = (1)
+    :param None: 
+    :param "hehe": 
+
+    """
     pass

 def func3(param1={0: 1, "a": None}):
+    """
+
+    :param param1:  (Default value = {0: 1)
+    :param "a": None}: 
+
+    """
     pass
dadadel commented 3 years ago

PR #96 fixes this issue.