This pull request applies a few lint rules to help teach good practices to new coders.
% ruff --statistics
42 F405 [ ] `AnimationGroup` may be undefined, or defined from star imports
6 F401 [*] `core.text.search_ast` imported but unused
5 F541 [*] f-string without any placeholders
2 E402 [ ] Module level import not at top of file
2 F841 [*] Local variable `french` is assigned to but never used
1 E701 [ ] Multiple statements on one line (colon)
1 F403 [ ] `from manim import *` used; unable to detect undefined names
% ruff rule F401
unused-import (F401)
Derived from the Pyflakes linter.
Fix is sometimes available.
What it does
Checks for unused imports.
Why is this bad?
Unused imports add a performance overhead at runtime, and risk creating
import cycles. They also increase the cognitive load of reading the code.
If an import statement is used to check for the availability or existence
of a module, consider using importlib.util.find_spec instead.
If an import statement is used to re-export a symbol as part of a module's
public interface, consider using a "redundant" import alias, which
instructs Ruff (and other tools) to respect the re-export, and avoid
marking it as unused, as in:
https://docs.astral.sh/ruff is the modern linter and formatter for Python code.
This pull request applies a few lint rules to help teach good practices to new coders.
%
ruff --statistics
%
ruff rule F401
unused-import (F401)
Derived from the Pyflakes linter.
Fix is sometimes available.
What it does
Checks for unused imports.
Why is this bad?
Unused imports add a performance overhead at runtime, and risk creating import cycles. They also increase the cognitive load of reading the code.
If an import statement is used to check for the availability or existence of a module, consider using
importlib.util.find_spec
instead.If an import statement is used to re-export a symbol as part of a module's public interface, consider using a "redundant" import alias, which instructs Ruff (and other tools) to respect the re-export, and avoid marking it as unused, as in:
Example
Use instead:
To check the availability of a module, use
importlib.util.find_spec
:Options
lint.ignore-init-module-imports
References
import
importlib.util.find_spec