mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #10279: autodoc: Default values are rendered as a string literal
When processing overloaded functions, autodoc unexpectedly renders its default values for kwonlyargs as a string literal unexpectedly
This commit is contained in:
parent
223b1a94f2
commit
82c9a7eb12
2
CHANGES
2
CHANGES
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user