flake8-print
Flake8 print plugin. This module provides a plugin for flake8, the Python code checker, specifically designed to identify and flag the use of `print` statements in Python files. The current version is 5.0.0, and it has a moderate release cadence with several updates per year, including major versions for significant changes.
Warnings
- breaking Python 2.7 support was officially dropped in version 4.0.0. Ensure your project runs on Python 3.7+ before upgrading to or using 4.0.0 and above.
- breaking In version 5.0.0, the error code namespace was moved from `T0xx` to `T2xx` (e.g., `T001` became `T201`). Projects relying on specific `ignore` lists or `noqa` comments for `T0xx` codes will need to update them to the new `T2xx` prefix.
- breaking Version 3.0.0 introduced a loss of multiline `noqa` support when the checker moved from a logical line checker with regex to an AST-based approach. While `2.0.0` supported `noqa` on multiline `print` statements, this was temporarily lost in `3.0.0` and `4.0.1` had a fix related to `noqa` detection.
- gotcha Incorrect or incomplete `noqa` comments. To ignore specific `flake8-print` errors, use `# noqa: T201` (for `print` statements) or `# noqa: T203` (for `pprint` statements) at the end of the line. Using just `# noqa` will ignore all `flake8` warnings on that line. Make sure to use the correct `T2xx` error codes from version 5.0.0 onwards.
Install
-
pip install flake8-print
Imports
- Usage as a plugin
No direct import is needed; flake8 automatically discovers installed plugins via entry points.
Quickstart
print('This line will be flagged by flake8-print')
# To demonstrate ignoring a specific print statement:
import os
if os.environ.get('DEBUG_MODE', 'False') == 'True':
print('Debug message') # noqa: T201