A function assigns a new value to a parameter before reading it, so the argument passed in is never used

tx0/python:parameter-overwrittenrecommendedwarningreliability/logicdepth fastbug

What it finds

When the first thing a function does with a parameter is to assign it, whatever the caller passed is thrown away, which usually means a wrong name on one side. Assignments that read the parameter, such as x = x or [], use it and are not reported; self and cls and parameters with defaults are left alone.

From the rule's source, parameter_overwritten.rs.

Example from the rule's tests
def load(path, mode):    path = "/etc/config"tx0 reports: the parameter is assigned before it is read    return open(path, mode) def normalize(items, key=None):    items = list(items)    key = key or str    return sorted(items, key=key) def later(value):    print(value)    value = 3    return value
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:parameter-overwritten" = "warning"

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:parameter-overwritten] reason="..."

tx0 explain tx0/python:parameter-overwritten shows the same in the terminal. Found a false positive? Report it.