-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add type hints for the _import_c_extension module #51767
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. Test Plan: Was able to have Pyre successfully type check the `caffe2/python` directory with this stub file plus a few other changes. [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 9a122f3 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
This was referenced Feb 5, 2021
Summary: The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. Test Plan: Was able to have Pyre successfully type check the `caffe2/python` directory with this stub file plus a few other changes. Differential Revision: [D26271726](https://our.internmc.facebook.com/intern/diff/D26271726) [ghstack-poisoned]
Summary: The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. Test Plan: Was able to have Pyre successfully type check the `caffe2/python` directory with this stub file plus a few other changes. Differential Revision: [D26271726](https://our.internmc.facebook.com/intern/diff/D26271726) [ghstack-poisoned]
simpkins
added a commit
that referenced
this pull request
Feb 12, 2021
Pull Request resolved: #51767 The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. ghstack-source-id: 121614356 Differential Revision: [D26271726](https://our.internmc.facebook.com/intern/diff/D26271726/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D26271726/)!
Summary: The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. Test Plan: Was able to have Pyre successfully type check the `caffe2/python` directory with this stub file plus a few other changes. Differential Revision: [D26271726](https://our.internmc.facebook.com/intern/diff/D26271726) [ghstack-poisoned]
simpkins
added a commit
that referenced
this pull request
Feb 17, 2021
Pull Request resolved: #51767 The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. ghstack-source-id: 121916324 Differential Revision: [D26271726](https://our.internmc.facebook.com/intern/diff/D26271726/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D26271726/)!
xsacha
pushed a commit
to xsacha/pytorch
that referenced
this pull request
Mar 31, 2021
Summary: Pull Request resolved: pytorch#51767 The `_import_c_extension.py` finds the right C extension library to use, and then simply re-exports all of the symbols that it defines. This adds a `_import_c_extension.pyi` file with type hints to let type checkers like Pyre and Mypy know the names of the symbols that will be re-exported from the C extension. This does not define all of the symbols provided by the C extension, but does define all of the symbols necessary to make type checkers happy about other code in the `caffe2/python` directory. ghstack-source-id: 121916324 Test Plan: Was able to have Pyre successfully type check the `caffe2/python` directory with this stub file plus a few other changes. Confirmed that all of the dependent projects affected by this report no new pyre issues in sandcastle. Ran `python test/test_type_hints.py` in the PyTorch github repository and confirmed it also passes. Differential Revision: D26271726 Pulled By: simpkins fbshipit-source-id: 6dbadcf02e0b2cc44a9e3cdabe9291c1250959b4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stack from ghstack:
Summary:
The
_import_c_extension.py
finds the right C extension library to use,and then simply re-exports all of the symbols that it defines.
This adds a
_import_c_extension.pyi
file with type hints to let typecheckers like Pyre and Mypy know the names of the symbols that will be
re-exported from the C extension.
This does not define all of the symbols provided by the C extension,
but does define all of the symbols necessary to make type checkers happy
about other code in the
caffe2/python
directory.Test Plan:
Was able to have Pyre successfully type check the
caffe2/python
directory with this stub file plus a few other changes.
Differential Revision: D26271726