A function rebinds a module variable through global
What it finds
A function that assigns module variables through global has effects that its callers cannot see from its signature, and its results depend on the order of earlier calls. Passing values in and out, or keeping the state in an object, makes the flow visible. Reported are global statements in functions for names the function assigns.
From the rule's source, global_statement.rs.
counter = 0 def bump(): global countertx0 reports: global counter lets this function rebind module state counter += 1 def read(): global counter return counter Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:global-statement" = "note"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:global-statement] reason="..."tx0 explain tx0/python:global-statement shows the same in the terminal. Found a false positive? Report it.