-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add unconditional import when type checking #6500
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
ananthsub
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.
thanks for the fix!
|
Hello @kandluis! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-03-18 16:28:08 UTC |
45c4292 to
3fc14f3
Compare
3fc14f3 to
2f6ce1a
Compare
|
Accidentally closed. Reopening. Refactored to keep only imports in the if/else branches. |
f7418f2 to
a862e32
Compare
SeanNaren
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.
I'll approve however not too well versed here, pinging @carmocca @kaushikb11 who may have more input.
|
@Borda Any updates ? |
|
Thanks @Borda for merging into refactors! :) |
What does this PR do?
Without this change, when type checking using
pyre(and possibly as well usingmypythough I've not verified this) imports such as:raise errors due to the fact that they're only conditionally imported at the module level.
A workaround is to change imports to the following:
However, large chunks of our documentation do not reflect this pattern. As such, this small update to the logic in the
__init__.pyfunction makes it so that when type checking (typing.TYPE_CHECKING === True) the imports are unconditional, fixing any warnings from the checkers.This is okay since the only time the imports do not occur is when were' in the build-phase of the library.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃