-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Use doctest directly to get docstring examples #50596
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
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.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
looks good.
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.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Codecov Report
@@ Coverage Diff @@
## master #50596 +/- ##
==========================================
- Coverage 81.07% 81.06% -0.01%
==========================================
Files 1915 1915
Lines 208621 208621
==========================================
- Hits 169139 169126 -13
- Misses 39482 39495 +13 |
This PR addresses a two-year-old TODO in
test/test_type_hints.py
by replacing most of the body of our customget_examples_from_docstring
function with a function from Python's built-indoctest.DocTestParser
class. This mostly made the parser more strict, catching a few errors in existing doctests:...
in multiline statements>>>
Also, as shown by the resulting diff of the untracked
test/generated_type_hints_smoketest.py
file (also linked from the test plan below), this introduces a few incidental changes as well:example_torch_promote_types
is now presentexample_torch_tensor___array_priority__
is added, although I can't tell where it comes fromexample_torch_tensor_align_as
are now presentexample_torch_tensor_stride
is now presentTest plan:
Checkout the base commit, typecheck the doctests, and save the generated file:
Then checkout this PR, do the same thing, and compare:
The test should succeed, and the diff should match this paste.