-
Notifications
You must be signed in to change notification settings - Fork 871
[Doc Generation] Support parsing posonlyargs when get function signature
#7578
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
Changes from 1 commit
330b364
26363bc
fabf85a
b154e08
db898fd
fbb6fd9
9ca407f
76f7408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -365,12 +365,25 @@ def gen_functions_args_str(node): | |||||||||||||||||||||||||
| str_args_list = [] | ||||||||||||||||||||||||||
| if isinstance(node, ast.FunctionDef): | ||||||||||||||||||||||||||
| # 'args', 'defaults', 'kw_defaults', 'kwarg', 'kwonlyargs', 'posonlyargs', 'vararg' | ||||||||||||||||||||||||||
| if node.args.posonlyargs is not None: | ||||||||||||||||||||||||||
| for arg in node.args.posonlyargs: | ||||||||||||||||||||||||||
| if not arg.arg == "self": | ||||||||||||||||||||||||||
| str_args_list.append(arg.arg) | ||||||||||||||||||||||||||
| str_args_list.append("/") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| for arg in node.args.args: | ||||||||||||||||||||||||||
| if not arg.arg == "self": | ||||||||||||||||||||||||||
| str_args_list.append(arg.arg) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| defarg_ind_start = len(str_args_list) - len(node.args.defaults) | ||||||||||||||||||||||||||
| if node.args.posonlyargs is not None and len(node.args.defaults) > len( | ||||||||||||||||||||||||||
| node.args.args | ||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||
| defarg_ind_start -= 1 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| for defarg_ind in range(len(node.args.defaults)): | ||||||||||||||||||||||||||
| if str_args_list[defarg_ind_start + defarg_ind] == "/": | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| defarg_ind_start += 1 | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| for defarg_ind in range(len(node.args.defaults)): | |
| if str_args_list[defarg_ind_start + defarg_ind] == "/": | |
| defarg_ind_start += 1 | |
| # Skip the "/" marker only once if it is at the start index | |
| if ( | |
| defarg_ind_start < len(str_args_list) | |
| and str_args_list[defarg_ind_start] == "/" | |
| ): | |
| defarg_ind_start += 1 | |
| for defarg_ind in range(len(node.args.defaults)): |
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.
The calculation of
defarg_ind_startadjustment is unclear. The logic assumes defaults overflow into posonlyargs territory by exactly one position, but this may not account for all edge cases. Consider adding a comment explaining the mathematical relationship between defaults, args, posonlyargs, and the '/' separator position.