Skip to content
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

[pycodestyle] Allow os.environ modifications between imports (E402) #10066

Merged
merged 1 commit into from Feb 20, 2024

Conversation

charliermarsh
Copy link
Member

Summary

Allows, e.g.:

import os

os.environ["WORLD_SIZE"] = "1"
os.putenv("CUDA_VISIBLE_DEVICES", "4")

import torch

For now, this is only allowed in preview.

Closes #10059

@charliermarsh charliermarsh added rule Implementing or modifying a lint rule preview Related to preview mode features labels Feb 20, 2024
Copy link

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -2 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

zulip/zulip (+0 -2 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- zproject/test_settings.py:21:1: E402 Module level import not at top of file
- zproject/test_settings.py:22:1: E402 Module level import not at top of file

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
E402 2 0 2 0 0

@charliermarsh charliermarsh merged commit 4997c68 into main Feb 20, 2024
17 checks passed
@charliermarsh charliermarsh deleted the charlie/sys branch February 20, 2024 18:24
nkxxll pushed a commit to nkxxll/ruff that referenced this pull request Mar 10, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

module-import-not-at-top-of-file ignore after os.environ
1 participant