-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
fixesRelated to suggested fixes for violationsRelated to suggested fixes for violations
Description
Description
The fix for shallow-copy-environ (PLW1507) changes the program’s behavior (by design) and should therefore be marked unsafe.
$ ruff --version
ruff 0.9.6
$ cat >plw1507.py <<'# EOF'
import copy
import os
os.environ["X"] = "0"
env = copy.copy(os.environ)
os.environ["X"] = "1"
print(env["X"])
# EOF
$ python plw1507.py
1
$ ruff --isolated check --preview --select PLW1507 plw1507.py --fix
Found 1 error (1 fixed, 0 remaining).
$ cat plw1507.py
import copy
import os
os.environ["X"] = "0"
env = os.environ.copy()
os.environ["X"] = "1"
print(env["X"])
$ python plw1507.py
0Metadata
Metadata
Assignees
Labels
fixesRelated to suggested fixes for violationsRelated to suggested fixes for violations