iotile / typedargs

API typechecking and command line shell generation package
GNU Lesser General Public License v3.0
1 stars 2 forks source link

Support recursive function annotations #82

Closed dvksirin closed 4 years ago

dvksirin commented 4 years ago

This PR makes @docannotate decorator to work correctly with complex types in type annotations. Supported complex types are List[t] and Dict[t, t] from builtin typing module. These types are internally mapped to our existing type factories list and map. For List[t] type - conversion from string and formatting of return value to string is supported For Dict[t, t] - only formatting of return value to string is supported

Example:

@docannotate
def func_list(arg: List[int]) -> List[int]:
    return arg

func_list("[1, 2, 3]")
# returns: [1, 2, 3]

Added an appropriate test case.

Notes:

Please, let me know if I should update this PR to support mentioned above.

Closes #62