create type hint stub files for module torch #16089
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was backported from #12500 but with tests removed and
the stub file checked in directly, so we don't have to also
make sure all build shenanigans work. Master will be properly
tested. The stub file was generated by running
'python setup.py create_pyi' and then copying the generated
pyi file in the build directory (find -name *.pyi) to torch/
Original PR description:
This is more a basis for discussion that a ready solution,
as it does lots of funny things, and for many of them
a better solution will be found.
use type hint introspection.
and torch.Tensor.
do this at the end of the build.
We use os.fork to only import the module in a child
process.
type hints on the native python functions in a way that
a) they're available in the usual place for Python 3
b) we stay Python 2 compatible
as examples, but the remaining ones still need to be done.
This could end up fixing #7318
cc @t-vi @soumith