A variable hides a builtin of the same name

tx0/python:shadowed-builtinstrictwarningsmell

What it finds

list = load(), def filter(...): a variable named like a builtin hides it in its scope, so a later list(...) there calls the value instead and fails, often far from the assignment.

Reported are assignments, loop targets, with targets, functions, classes and imports in module and function scopes. Class attributes, which do not hide anything outside the class body, are left alone, and so are parameters, where names such as id and type are common, and names of rarely called builtins such as copyright and license.

From the rule's source, shadowed_builtin.rs.

Example from the rule's tests
import json as listtx0 reports: list hides the builtin of the same name in this scope  def collect(items, id):    filter = [x for x in items if x]tx0 reports: filter hides the builtin of the same name    return filter, id  class Model:    type = "model"    id = 0  def input():tx0 reports: input hides the builtin    return 1
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 strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:shadowed-builtin" = "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:shadowed-builtin] reason="..."

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