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
always use separate fields for param and type in ext.autodoc.typehints #7562
Conversation
this fixes issues where annotations such as `x: typing.Tuple[int, int]` will be transformed to `:field typing.Tuple[int, int] x:`, which renders as `*int] x* (**typing.Tuple[int,**) -- `
Tests probably should be added to this one: sphinx/tests/test_ext_autodoc_configs.py Lines 564 to 578 in bee44be
which pulls signatures from this file sphinx/tests/roots/test-ext-autodoc/target/typehints.py Lines 14 to 15 in bee44be
It might make sense to rewrite the test in the form of |
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.
LGTM!
I'll merge this after updates of testcase. Please follow @eric-wieser 's advice :-)
Somehow, when I set up the test like this, I don't get any typehints in the output at all. Why is that? @pytest.mark.sphinx('text', testroot='ext-autodoc',
confoverrides={'autodoc_typehints': "description"})
def test_autodoc_typehints_description(app):
options = {"members": None,
"undoc-members": True}
actual = do_autodoc(app, 'module', 'target.typehints', options)
assert list(actual) == ... yields:
So the built RST looks identical to autodoc_typehints=None. |
That should be |
No difference with Typehints are added on |
Huh, that's a pain, but explains why that test is written differently. I don't know how to proceed here, @tk0miya will have to advise what to do next. |
Yes,
|
a. add the warning to the expected warnings in |
Oh, sorry. Let's choose the c. It's better not to share an example between testcases. The last comment is my wrong. |
c43fcfc
to
4712980
Compare
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.
LGTM!
Thank you for your contribution! |
Note: manually merged into 3.x branch |
this fixes issues where annotations such as
x: typing.Tuple[int, int]
will be transformed to
:field typing.Tuple[int, int] x:
, which rendersas
*int] x* (**typing.Tuple[int,**) --
Feature or Bugfix
Detail
Minimum example:
Unfortunately, I didn't find a testsuite for
sphinx.ext.autodoc.typehints
, so I can't promise that this doesn't have any weird side effects.