diff --git a/CHANGES b/CHANGES index e9298d68451..7037723fe50 100644 --- a/CHANGES +++ b/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 diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index da548bd3ecd..81c2ba6cd80 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -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))