-
-
Notifications
You must be signed in to change notification settings - Fork 108
Allow py310 style annotations (PEP563) when using from __future__ import annotations #184
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
Conversation
@agronholm, what do you think about this? This is relevant for all projects that use |
Sure, I will take a look later. I will need this for my own projects too. |
9e4ddf1
to
139b5b9
Compare
This PR isn't going to work as-is because Python 3.6 is still supported and that future import doesn't work there. |
Do you have any ideas/suggestions to make it work? Dropping 3.6 is one solution. Many packages in the scientific Python community follow NEP 29. Even though a package might still support 3.6, I imagine no actively developed package still used 3.6 to build their docs. |
The PyPI statistics don't support that supposition. An extra "dummy module" for 3.7+ only could work. |
Good suggestion, I will try that tomorrow! |
f12395d
to
267ba40
Compare
@agronholm, I have added a dummy module that is tested only for Python ≥ 3.7. |
a41ad9f
to
959fa8c
Compare
Maybe you should first make sure the linting checks pass locally? |
Done. I have also renamed Not sure how it would have worked before. |
The idea was that anyone wishing to use pre-commit would have a template, but would not be required to use the exact versions there. |
sphinx_autodoc_typehints.py
Outdated
if sys.version_info < (3, 8): | ||
# Only Pythoh ≥ 3.8 supports PEP563. |
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.
Umm, yes, it does. It says so in PEP 563 and I have a project that depends on that.
The CI is now failing exactly like master is failing. I can make the appropriate changes to make it pass (if the generated output is OK). |
Please do – although I would like to understand why it failed before this is merged. The same code in master passed some time before, so this is likely due to changes in Sphinx itself. |
@agronholm, 5065d94 contains the changes required to make the tests pass. Unfortunately, I don't have time to figure out what changed in Sphinx to cause this change. |
Python 3.10 is still failing in many places, except not in the test I added |
Those failures seem to have a singular cause – something involving |
I have locally tested my latest changes on Python 3.10, and now it seems like all CI jobs should pass. |
Because I seem to need approval to run the CI every single time, I have set it up on my fork: https://github.com/basnijholt/sphinx-autodoc-typehints/actions/runs/1345088994. It now all passes. |
Ping @agronholm 😃 |
Yeah, sorry, I've been meaning to get back to this. I'll take another look tonight. |
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.
Some change requests, some questions.
@basnijholt I've rebased on main, can you please fix the CI, thanks! |
I'll be AFK for more than a month. @agronholm wanted to check out the remaining failure cases I believe. |
Signed-off-by: Bernát Gábor <[email protected]>
Thanks for merging this and fixing the tests 🎉😃😄 |
Yeah, interestingly the future annotation has an extra zero at the end in 3.8 or later, see python/cpython@5055c27#diff-eb46a68cfb368cc943fe36ad91dba3692682ab4454221fefd6abab8757682ab0 |
This allows one to annotate in Python 3.10 style (PEP563) when
from __future__ import annotations
is used.e.g.:
will work