-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
module-import-not-at-top-of-file
ignore after os.environ
#10059
Comments
I think I agree with this. We already ignore |
Added in #10066, though it'll be |
…02`) (astral-sh#10066) ## Summary Allows, e.g.: ```python import os os.environ["WORLD_SIZE"] = "1" os.putenv("CUDA_VISIBLE_DEVICES", "4") import torch ``` For now, this is only allowed in preview. Closes astral-sh#10059
@charliermarsh it might make sense to allow warnings.filterwarnings in between as well. I sometimes have to add that in between imports to silence the warnings |
I just use In my case it's custom logger configuration. I need to setup logger, before calling any getLogger. Since I use logger in other files, I have to do it before imports. |
Sometimes you need to set an environment variable before importing a package, for example:
See: https://discuss.pytorch.org/t/runtimeerror-device-0-device-num-gpus-internal-assert-failed/178118/6
My suggestion is to ignore E402
module-import-not-at-top-of-file
if it comes after aos.environ
statement, similar to #9047The text was updated successfully, but these errors were encountered: