Pyflakes is a fast, lightweight static analysis tool that meticulously checks Python code for common programming errors without executing it. It primarily identifies issues such as unused imports, undefined names, and redefined variables. Focusing solely on error detection, rather than code style, it aims for speed and minimizes false positives. Currently at version 3.4.0, Pyflakes supports Python 3.9 and newer, and is actively maintained by the PyCQA organization.
pip install pyflakesNo compatibility data collected yet for this library.
Demonstrates how to run Pyflakes from the command line on a Python file to detect errors. Pyflakes outputs issues to stdout.
Upgrade your Python environment to 3.9 or a newer active version.
For combined style and error checking, use `flake8` (`pip install flake8`) which integrates Pyflakes along with other tools like `pycodestyle` (formerly `pep8`) and `mccabe`.
If configuration is required, consider using `flake8` which provides extensive configuration options, or integrate Pyflakes into a larger system that manages its invocation and output filtering.
Integrators should rely on Pyflakes's standard command-line output parsing where possible, or pin Pyflakes to a specific minor version to prevent unexpected breakage from internal API changes.
Review the reported issues in your code. Unused imports/variables may indicate dead code or refactoring opportunities. Undefined names are critical runtime errors. Address these directly or, if intentional, consider using appropriate suppression comments (e.g., '# noqa') as per Pyflakes's guidelines.
Remove the unused import statement to keep the codebase clean and avoid unnecessary dependencies.
Ensure the 'name' is correctly defined before its first use, or that the necessary module/object containing 'name' is properly imported.
Initialize the variable with a default value before its first use, or ensure it is assigned a value on all possible code paths before being referenced. If intending to modify a global variable, use the `global` keyword.
Refactor the code to avoid redundant definitions. If the redefinition is intentional, ensure the first definition is used or remove the unnecessary initial definition.
No dependency data recorded yet.