-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: retrieve keyword arguments for docstrings #389
Conversation
docfx_yaml/extension.py
Outdated
|
||
# Retrieve arguments from various source,s like `argspec.args`, | ||
# `argspec.kwonlyargs` for positional/keyword arguments. | ||
args_to_iterate = argspec.args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider original_args
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
arg_map['var_type'] = type_map[arg] | ||
args.append(arg_map) | ||
|
||
annotations = getattr(argspec, 'annotations', []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally the test would involve updating the goldens as this function is called directly from Sphinx and can't be mocked easily.
I could refactor the logic out and add unit tests separately as a followup, and release only when the refactoring of this method is done.
Co-authored-by: Tyler Bui-Palsulich <26876514+tbpg@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Please take a look again.
docfx_yaml/extension.py
Outdated
|
||
# Retrieve arguments from various source,s like `argspec.args`, | ||
# `argspec.kwonlyargs` for positional/keyword arguments. | ||
args_to_iterate = argspec.args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
arg_map['var_type'] = type_map[arg] | ||
args.append(arg_map) | ||
|
||
annotations = getattr(argspec, 'annotations', []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally the test would involve updating the goldens as this function is called directly from Sphinx and can't be mocked easily.
I could refactor the logic out and add unit tests separately as a followup, and release only when the refactoring of this method is done.
Ran tests over several libraries locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, please make sure this has golden coverage somewhere (the *
arg not breaking default args that follow).
From
inspect.getfullargspec
, keyword arguments were stored as different attributes, underkwonlyargs
andkwonlydefaults
.kwonlyargs
kwonlydefaults
as well, for default values stored for keyword arguments. Interestingly,defaults
are stored as tuples of values butkwonlydefaults
is stored as name & value KVP, so I've directly addressed this. Since dictionaries retain order, this won't mess up the order for existing defaults algorithm.Fixes #313. See b/358448617 for context and staging to verify the fixes.