A value other than a string is assigned to os.environ
What it finds
os.environ["WORKERS"] = 4: environment variables hold strings, and os.environ raises TypeError: str expected, not int for anything else. str(4), or "4", is what the variable can hold.
Reported are number, True, False and None literals assigned to an item of os.environ.
From the rule's source, non_string_environ_value.rs.
import osfrom os import environ def configure(): os.environ["WORKERS"] = 4tx0 reports: os.environ only holds strings, so assigning 4 raises TypeError environ["DEBUG"] = Truetx0 reports: assigning True raises TypeError os.environ["WORKERS"] = "4" settings = {} settings["WORKERS"] = 4 return settings Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/python:non-string-environ-value" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:non-string-environ-value] reason="..."tx0 explain tx0/python:non-string-environ-value shows the same in the terminal. Found a false positive? Report it.