Registry / testing / flake8-debugger

flake8-debugger

JSON →
library4.1.2pypypiunverified

flake8-debugger is a plugin for the flake8 code quality tool that checks for the presence of common debugger statements (like `pdb.set_trace()`, `ipdb.set_trace()`, and `breakpoint()`) in Python code. This helps prevent accidental commits of debugging code into production. The current version is 4.1.2. Releases are made periodically, typically following updates to Python versions or the flake8 ecosystem.

pip install flake8-debugger
INSTALL
IMPORT
SIG · FLAKE8-DEBUGGER
F
flake8-debugger
testingpythonv4.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Install flake8-debugger alongside flake8. It automatically integrates. Create a Python file with a debugger statement and run flake8 on it to see the plugin in action.

import os def my_function(): # This line will be flagged by flake8-debugger if os.environ.get('DEBUG_ENABLED', 'false').lower() == 'true': import pdb; pdb.set_trace() print("Hello, world!") my_function() # To run this example: # 1. Save the code as example.py # 2. Run 'pip install flake8 flake8-debugger' # 3. Run 'flake8 example.py' in your terminal # Expected output will include an error like 'example.py:6:9: D001 debugger detected'
Debug
Known issues
breakingSupport for Python 3.6 was dropped in version 4.1.0.
fix
Ensure your project uses Python 3.7 or newer. Upgrade your Python environment if necessary.
affects: >=4.1.0
breakingOfficial support for Python 2.7 was dropped in version 4.0.0.
fix
Migrate your project to Python 3.x. Version 3.1.0 was the last to explicitly support Python 2.7.
affects: >=4.0.0
gotchaflake8-debugger works as a plugin and does not require any explicit imports or configuration files to enable. Simply installing it makes it active when you run the `flake8` command.
fix
No fix needed, this is intended behavior. Just ensure `flake8` is installed and run it as usual.
affects: All versions
gotchaWhile comprehensive, flake8-debugger relies on AST parsing and might not catch highly obfuscated or dynamic debugger calls. It primarily targets common patterns like `pdb.set_trace()` or `breakpoint()`.
fix
For critical applications, supplement static analysis with runtime checks or enforce strict code review policies against debugging statements.
affects: All versions
Errors
Common errors & fixes
flake8 does not report F999 (or any warnings) for pdb.set_trace() / breakpoint()
The flake8-debugger plugin is either not installed in the same environment as flake8, not recognized by flake8, or an older version is being used that doesn't correctly detect the debugger statements.
fix
Ensure flake8-debugger is installed and up-to-date in your Python environment (`pip install --upgrade flake8-debugger`). Verify that flake8 recognizes the plugin by running `flake8 --version` and checking for 'flake8-debugger' in the output. Also, ensure the Python version running flake8 is compatible with the installed flake8-debugger version (e.g., Python 3.7+ for recent versions).
E999 SyntaxError: invalid syntax
This error occurs when flake8 (and its plugins, including flake8-debugger) attempts to parse Python code using a Python interpreter version that is incompatible with the syntax in the code (e.g., linting Python 3 code with a flake8 installed in a Python 2 environment, or vice-versa).
fix
Ensure that flake8 is installed and run with the same Python version that your code is written for. It is recommended to use a virtual environment, activate it, and install flake8 and flake8-debugger within that environment.
F999 (or any flake8-debugger specific codes) reported, but I want to ignore them.
The flake8-debugger plugin is correctly identifying debugger statements, and the user needs to configure flake8 to ignore these specific warnings.
fix
To ignore F999: For a single line, add `# noqa: F999` at the end of the line. For an entire file, add `# flake8: noqa` at the top of the file, or use the `--per-file-ignores` option in your configuration (e.g., `per-file-ignores = path/to/file.py:F999`). To ignore globally, add `ignore = F999` to the `[flake8]` section in your `setup.cfg`, `tox.ini`, or `.flake8` configuration file, or use `flake8 --ignore F999` on the command line.
flake8-debugger is installed but doesn't seem to be running or checking anything.
While not a direct error message, this is a common problem where the plugin is installed but its checks are not being applied. This can be due to flake8 not properly loading the plugin or configuration issues.
fix
First, confirm `flake8-debugger` is installed and recognized (`pip install --upgrade flake8-debugger` then `flake8 --version`). Ensure your flake8 configuration (e.g., `setup.cfg`, `pyproject.toml`, `.flake8`) does not accidentally exclude the F999 code or the files where you expect the checks to run. Review the `exclude` and `ignore` settings in your flake8 configuration.
Upgrade
Version history
4.1.2latest on PyPI · released Apr 30, 2022
Audit
Dependencies
flake8requiredThis is a plugin for flake8 and requires flake8 to be installed to function. While not an explicit install_requires dependency, it's a functional requirement.
Agent activity
6 hits · last 30 days
node
6
Resources
flake8-debugger — pip install flake8-debugger · libregistry