A name is used that the file never binds and that is not a builtin

tx0/python:undefined-namerecommendedwarningbug

What it finds

return reslt where only result exists: a name that the file binds nowhere, and that is not a builtin, raises NameError when the line runs. Usually it is a typo, a missing import, or a name that was renamed elsewhere.

Files with a star import, which can bind any name, and files that call globals(), exec or vars(), which can define names this check does not see, are left alone. So are the names Python defines in every module, such as __file__, names it defines in classes and methods, and names of Python 2 and of particular platforms, such as unicode or WindowsError, which code uses behind checks of the version, and the builtins newer versions add, such as frozendict. Files with lazy import statements are left alone too.

From the rule's source, undefined_name.rs.

Example from the rule's tests
import os  def run(path):    result = os.path.join(path, "x")    return reslttx0 reports: reslt is not defined anywhere in this file, so this raises NameError  def other():    return __file__, len(run(1)), missing_nametx0 reports: missing_name is not defined anywhere
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:undefined-name" = "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:undefined-name] reason="..."

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