This rule raises an issue when os.environ is shallow-copied with copy.copy().
os.environ is not a plain dict. It is a proxy mapping that reads and writes the process environment.
copy.copy(os.environ) creates a shallow copy of that proxy. Mutations on the copy still update the real process environment, which is
almost never what developers expect when they ask for a copy.
import copy import os env = copy.copy(os.environ) env["MY_VAR"] = "value" # os.environ["MY_VAR"] is also "value"
os.environ.copy() returns an independent dict snapshot. Changes to that dictionary do not affect the process
environment.
Replace copy.copy(os.environ) with os.environ.copy().
import copy import os env = copy.copy(os.environ) # Noncompliant
import os env = os.environ.copy()
os.environ