Skip to content

undefined-local-with-nested-import-star-usage

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a star import in a function or class.

Python rejects the file with SyntaxError: import * only allowed at module level since a function’s local names are fixed when it is compiled and cannot depend on what a module defines.

To fix, import the names you need, or move the import to module level.

Reported
...
def nested():
from other import *
...
python:
lint:
rules:
undefined-local-with-nested-import-star-usage: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line undefined-local-with-nested-import-star-usage in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff F406 full