-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[DOC] Use type hints to show annotation in the docs #79086
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
🔗 Helpful links
❌ 1 New Failures, 1 PendingAs of commit 4e4a735308 (more details on the Dr. CI page): Expand to see more
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages
|
Thanks for working on this @ShawnZhong! CI isn't being all that helpful here just yet it looks like: There's a lot of CI failures though, the first one I looked at contained:
so as happens more often, there may be a conflict between what Mypy/Sphinx wants and what the PyTorch JIT can actually understand. |
Yep. It seems that there is some issue with postponed annotations (PEP 563) and JIT. I'm trying to fix them in a separate PR: #79096. If the JIT issue cannot be easily fixed, I might leave this PR without For future reference, the current commit is 646b745 and one error message is available at https://github.com/pytorch/pytorch/runs/6784944582?check_suite_focus=true. |
You can ignore the backward compat test failure as it is a master breakage. |
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.
The change sounds ok to me.
Do we want to merge this without the autodoc_type_aliases
as it is an improvement already?
Do we have any way to check which part of the doc this is changing to make sure it all behaves well? Or we can just spot check some functions?
cc @svekars
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
@albanD can we include this for the new release, as this greatly improve the documentation reading experience? |
Taking the liberty to add it to the milestone. Please feel free to change |
Hey! |
@ShawnZhong thanks! |
/easycla As part of the transition to the PyTorch Foundation, this project now requires contributions be covered under the new CLA. See #85559 for additional details. This comment will trigger a new check of this PR. If you are already covered, you will simply see a new "EasyCLA" check that passes. If you are not covered, a bot will leave a new comment with a link to sign. |
|
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/79086
Note: Links to docs will display an error until the docs builds have been completed. ✅ No Failures, 2 PendingAs of commit a33365a: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Just rebased the branch to the latest master. I went over some generated docs, and they look good to me. Something worth noting:
|
Any updates on the review? |
@albanD bump |
@pytorchbot merge -f "This is just a doc config update" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Hey @ShawnZhong. |
Fixes #44964 Use type hints in the code to show type annotations in the parameters section of the docs. For the parameters already documented in the docstring, but lack the type annotation, the type hints from the code are used: | [Before](https://pytorch.org/docs/master/generated/torch.nn.AdaptiveMaxPool1d.html) | [After](https://docs-preview.pytorch.org/79086/generated/torch.nn.AdaptiveMaxPool1d.html) | | --- | --- | | <img width="462" alt="image" src="https://user-images.githubusercontent.com/6421097/172954756-96d2d8a6-7df9-4c0f-ad34-c12912a5a740.png"> | <img width="479" alt="image" src="https://user-images.githubusercontent.com/6421097/172954770-a6ce2425-99a6-4853-ac2c-e182c3849344.png"> | | [Before](https://pytorch.org/docs/master/generated/torch.nn.Linear.html) | [After](https://docs-preview.pytorch.org/79086/generated/torch.nn.Linear.html) | | --- | --- | | <img width="482" alt="image" src="https://user-images.githubusercontent.com/6421097/172954992-10ce6b48-44a2-487e-b855-2a15a50805bb.png"> | <img width="471" alt="image" src="https://user-images.githubusercontent.com/6421097/172954839-84012ce6-bf42-432c-9226-d3e81500e72d.png"> | Ref: - PR #49294 removed type annotations from signatures in HTML docs. - Sphinx version was bumped to 5.0.0 in PR #70309 - Duplicated (closed) issues: #78311 and #77501 Pull Request resolved: #79086 Approved by: https://github.com/malfet (cherry picked from commit e552cf1)
Fixes #44964 Use type hints in the code to show type annotations in the parameters section of the docs. For the parameters already documented in the docstring, but lack the type annotation, the type hints from the code are used: | [Before](https://pytorch.org/docs/master/generated/torch.nn.AdaptiveMaxPool1d.html) | [After](https://docs-preview.pytorch.org/79086/generated/torch.nn.AdaptiveMaxPool1d.html) | | --- | --- | | <img width="462" alt="image" src="https://user-images.githubusercontent.com/6421097/172954756-96d2d8a6-7df9-4c0f-ad34-c12912a5a740.png"> | <img width="479" alt="image" src="https://user-images.githubusercontent.com/6421097/172954770-a6ce2425-99a6-4853-ac2c-e182c3849344.png"> | | [Before](https://pytorch.org/docs/master/generated/torch.nn.Linear.html) | [After](https://docs-preview.pytorch.org/79086/generated/torch.nn.Linear.html) | | --- | --- | | <img width="482" alt="image" src="https://user-images.githubusercontent.com/6421097/172954992-10ce6b48-44a2-487e-b855-2a15a50805bb.png"> | <img width="471" alt="image" src="https://user-images.githubusercontent.com/6421097/172954839-84012ce6-bf42-432c-9226-d3e81500e72d.png"> | Ref: - PR #49294 removed type annotations from signatures in HTML docs. - Sphinx version was bumped to 5.0.0 in PR #70309 - Duplicated (closed) issues: #78311 and #77501 Pull Request resolved: #79086 Approved by: https://github.com/malfet (cherry picked from commit e552cf1) Co-authored-by: Shawn Zhong <github@shawnzhong.com>
Fixes #44964
Use type hints in the code to show type annotations in the parameters section of the docs.
For the parameters already documented in the docstring, but lack the type annotation, the type hints from the code are used:
Ref: