-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Docstring.params
(and others) to be dict-like types
#89
Comments
Attribute interface would be better as it would be consistent with the rest of the api. Ei fndocs = parse(fn.__doc__)
fndocs.params.argument1.description Is cleaner than: fndocs = parse(fn.__doc__)
fndocs.params['argument1'].description |
Unfortunately this would not play quite well with type-hints |
I'm not sure what you mean. Right now the Docstring class has attribute params with type List[DocstringParam]. Instead we could have class DocstringParams():
def __init__(self, params_list: List[DocstringParam]):
for param in params_list:
setattr(self, param.arg_name, param)
Docstring
self.params: DocstringParams = DocstringParams(list_of_DocstringParam_objects) type hint should show Docstring.param as DocstringParams. Right now it just shows List[DocstringParam]. Or if you are talking about argument type hints, they are still available with docstring.params.argument1.type_name |
It's about (statically) type-hinting for |
Maybe I'm missing something but would argument1 not be type DocstringParam? as would all the param attributes of DocstingParams. We're not type hinting with the arguments actual type anyways, its just a string parameter under type_name |
I think dict-like access would be preferable. You could use a TypedDict or simply |
In order to make extracting the necessary attribute's docstring simpler, it would be great if it had a dict-like interface. attribute interface would also be great to have, but might require more sophisticated refactoring.
The text was updated successfully, but these errors were encountered: