names_undefined
error
Undefined variable used in a return statement
Flags any name referenced in a return expression — bare (return x), the base of an attribute/subscript chain (return x.y), a call argument, or the **callee of a call** (return x()) — that is not defined in scope. A name is considered defined if it is a parameter, a local assignment (=, for, with), a module-level function, class, variable, or import, an enclosing scope's binding, a cross-module imported symbol, or a builtin.
def compute() -> int:
return undefined_name # never defined → E0018
return undefined_fn() # undefined callee → E0018
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
names_undefined down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/names_undefined