-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Improves type-checking guards. #43339
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
💊 CI failures summary and remediationsAs of commit 5951221 (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 on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 13 times. |
6df4079 to
36cb797
Compare
|
The failed tests all seem to be of the form where the imported signature has a different parameter name from the local one, or of the form where Searching for the names, I think the problem is a mismatch between I think I can fix the parameter name mismatches easily enough, but the |
|
Thanks @andyljones. I'd advise marking these |
36cb797 to
d325d2e
Compare
PR pytorch#38157 fixed type checking for mypy by including `if False` guards on some type-checker-only imports. However other typecheckers - like pyright - will respect this logic and ignore the imports. Using the TYPE_CHECKING var instead means both mypy and pyright will work.
d325d2e to
5951221
Compare
Done & done. |
facebook-github-bot
left a comment
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.
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Pretty weird internal error that is blocking this land: |
|
nvm, it passed when i ran it locally |
PR #38157 fixed type checking for mypy by including
if Falseguards on some type-checker-only imports. However other typecheckers - like pyright - will respect this logic and ignore the imports. Usingif TYPE_CHECKINGinstead means both mypy and pyright will work correctly.For background, an example of where the current code fails is if you make a file
tmp.pywith the contentsThen
pyright tmp.py --libwill fail with a"ones" is not a known member of moduleerror. This is because it can't find the_VariableFunctions.pyistub file, as pyright respects theif Falselogic. After adding theTYPE_CHECKINGguard, all works correctly.Credit to @erictraut for suggesting the fix.