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 duplicated *args and **kwargs with autodoc_typehints #9648
Conversation
45059c9
to
16e484e
Compare
@@ -30,7 +36,9 @@ def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any, | |||
sig = inspect.signature(obj, type_aliases=app.config.autodoc_type_aliases) | |||
for param in sig.parameters.values(): | |||
if param.annotation is not param.empty: | |||
annotation[param.name] = typing.stringify(param.annotation) | |||
prefix = __ANNOTATION_KIND_TO_PARAM_PREFIX.get(param.kind, '') |
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.
This change will cause the :param:
definition without prefixes (ex. args
, kwargs
). So this change is not good. I think it would be better to change modify_field_list()
and augment_descriptions_with_types()
instead (without modifying this annotation
data).
I noticed this docstring causes warnings because
Here are warnings:
It will work fine if we escape
I'm not sure this feature is really needed? |
f1a4eef
to
42caa49
Compare
This is needed for the Numpy and Google docstring formats, which napoleon converts to |
Oh, I missed numpydoc format. Indeed, it recommends prepending stars. |
be7d4c4
to
c068c2d
Compare
In basic usage of autodoc (docstring), `args` and `kwargs` arguments are marked up without stars. But numpydoc style recommends to mark them up with stars. This adds support for starred arguments in docstrings to `autodoc_typehints` feature.
In basic usage of autodoc (docstring), `args` and `kwargs` arguments are marked up without stars. But numpydoc style recommends to mark them up with stars. This adds support for starred arguments in docstrings to `autodoc_typehints` feature.
…tion_and_stared_args Fix #9648: autodoc: *args and **kwargs entries are duplicated
I merged #10451 instead of this. Thank you for your proposal and contribution! |
Fix duplicated *args and **kwargs with autodoc_typehints
Bugfix
Detail
Consider this
when using the autodoc extension and the setting
autodoc_typehints = "description"
.WIth sphinx 4.2.0, the current output is
where the *args and **kwargs are duplicated and incomplete.
The expected output is