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
create type hint stub files for module torch #12500
Commits on Oct 9, 2018
-
create type hint stub files for module torch
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. - Initial stab at creating a type torch/__init__.pyi . - We only do this for Python 3 because we want to use type hint introspection. - So far, we only aim at doing this for torch functions and torch.Tensor. - We need to import the newly build torch. Thus we do this at the end of the build. We use os.fork to only import the module in a child process. - We use an annotate decorator to be able to put 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 - Some annotatons in torch/functional.py are provided as examples, but the remaining ones still need to be done. This could end up fixing pytorch#7318
-
Commits on Oct 10, 2018
-
Improve type mapping, add manual annotations
- Add manual tensor() annotation, thank you, @elliotwite. - Create class stubs for device etc. - Improve type mapping. Thank you, Simon, for the review comments.
Commits on Oct 16, 2018
Commits on Oct 18, 2018
Commits on Oct 19, 2018
-
Add test and update generation
- Add test_type_hints.py: For testing we compile the docstring examples into one large file and run mypy over it. - Make the test pass by adding lots of cases to gen_pyi.py.
-
-
-
-
-
Commits on Oct 20, 2018
Commits on Dec 17, 2018
Commits on Jan 10, 2019
Commits on Jan 15, 2019
Commits on Jan 17, 2019
-
Generate pyi in-place, also general formatting and commenting
- Previously, type hints didn't work for 'develop' builds, because the pyi was put into a generated directory and consequently not picked up by the Python interpreter. It's a lot easier, and consistent with how we generate other files in PyTorch, to just generate the file in place. I need to test if the pyi file actually gets installed. - I figured out why mypy didn't work in the default directory; it's because we had a mypy.ini which specified Python 2. I fixed this by making our test file Python 2 syntax compatible. - I added some more comments, and adjusted formatting to my taste. Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-
Don't assume data exists, and comment about mypy bug workaround
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-
Don't install mypy in environments where it doesn't work
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Commits on Jan 22, 2019
-
Restructure so that it works with Python 2
This is done by deleting all of annotation based inference; instead we'll just write those signatures out manually. A bit of code reorging happened along the way. I still need to add back the direct Python implementations; incoming soon! Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Commits on Jan 23, 2019
-
-
Well, maybe this fixes the build
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-
Try to make the file write more robust
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Commits on Jan 24, 2019
-
Remove torch dependency entirely
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Commits on Jan 28, 2019
-
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-
Handle the rest of the problems, I think
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
-