pre-commit autoupdate 2025-10-04 #70
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
%
pre-commit autoupdate
%
pre-commit run --all-files
There are lots of perfectly valid reasons to ignore:
%
ruff rule PLC0415
import-outside-top-level (PLC0415)
Derived from the Pylint linter.
What it does
Checks for
import
statements outside of a module's top-level scope, suchas within a function or class definition.
Why is this bad?
PEP 8 recommends placing imports not only at the top-level of a module,
but at the very top of the file, "just after any module comments and
docstrings, and before module globals and constants."
import
statements have effects that are global in scope; defining them atthe top level has a number of benefits. For example, it makes it easier to
identify the dependencies of a module, and ensures that any invalid imports
are caught regardless of whether a specific function is called or class is
instantiated.
An import statement would typically be placed within a function only to
avoid a circular dependency, to defer a costly module load, or to avoid
loading a dependency altogether in a certain runtime environment.
Example
Use instead:
See also
This rule will ignore import statements configured in
lint.flake8-tidy-imports.banned-module-level-imports
if the rule
banned-module-level-imports
is enabled.