A module-level import comes after other code
What it finds
PEP 8 places imports at the top of a module, after its docstring and before other code, so that the dependencies of a module can be seen at once. Reported are imports directly at module level that follow a statement other than an import, the docstring, __future__ imports, assignments to dunder names such as __all__, and calls that commonly set up imports, such as sys.path changes and warnings filters. Imports inside if, try and functions are not affected.
From the rule's source, late_module_import.rs.
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:
[rules]
"tx0/python:late-module-import" = "note"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:late-module-import] reason="..."tx0 explain tx0/python:late-module-import shows the same in the terminal. Found a false positive? Report it.