Skip to content
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 #10279: autodoc: Default values are rendered as a string literal #10315

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -65,6 +65,8 @@ Features added
Bugs fixed
----------

* #10279: autodoc: Default values for keyword only arguments in overloaded
functions are rendered as a string literal
* #10236: html search: objects are duplicated in search result
* #9962: texinfo: Deprecation message for ``@definfoenclose`` command on
bulding texinfo document
Expand Down
5 changes: 4 additions & 1 deletion sphinx/util/inspect.py
Expand Up @@ -775,7 +775,10 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
annotation=annotation))

for i, arg in enumerate(args.kwonlyargs):
default = ast_unparse(args.kw_defaults[i], code) or Parameter.empty # type: ignore
if args.kw_defaults[i] is None:
default = Parameter.empty
else:
default = DefaultValue(ast_unparse(args.kw_defaults[i], code)) # type: ignore # NOQA
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
params.append(Parameter(arg.arg, Parameter.KEYWORD_ONLY, default=default,
annotation=annotation))
Expand Down