Registry / testing / flake8-blind-except

flake8-blind-except

JSON →
library0.2.1pypypiunverified

flake8-blind-except is a `flake8` extension that identifies "blind" `except:` statements in Python code, specifically bare `except:` or `except Exception:` without logging or re-raising. It helps enforce better error handling practices by flagging these broad catches. The current version is 0.2.1, and its release cadence is slow, indicating a mature and stable plugin.

pip install flake8-blind-except
INSTALL
IMPORT
SIG · FLAKE8-BLIND-EXCEP
F
flake8-blind-except
testingpythonv0.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

To quickly verify `flake8-blind-except`, install both `flake8` and the plugin. Then, create a simple Python file containing a bare `except:` statement. Running `flake8` against this file will demonstrate the plugin's `B902` error detection.

# 1. Install flake8 and the plugin # pip install flake8 flake8-blind-except # 2. Create a Python file with a blind except (e.g., my_module.py) # with open('my_module.py', 'w') as f: # f.write("""try:\n 1/0\nexcept:\n pass # This will trigger B902\n""") # 3. Run flake8 on the file # This command will output the B902 error for the blind except # flake8 my_module.py
Debug
Known issues
gotchaAs a `flake8` plugin, `flake8-blind-except` relies on `flake8` itself being installed and correctly configured. Ensure `flake8` is installed in the same environment.
fix
Ensure `pip install flake8` is run in your environment alongside `flake8-blind-except`.
affects: All versions
gotchaExisting `flake8` configuration files (e.g., `pyproject.toml`, `setup.cfg`, `.flake8`) can override which checks are run. If `B902` errors are not showing up, check your `ignore` or `select` directives.
fix
Review your `flake8` configuration to ensure `B902` is not explicitly ignored and that no `select` directive is preventing its execution.
affects: All versions
gotchaThe plugin specifically targets 'blind' excepts (bare `except:` or `except Exception:`). It does not flag more specific but still overly broad catches like `except BaseException:`, which may still hide important errors.
fix
For more rigorous error handling checks, consider additional `flake8` plugins or custom rules that analyze exception types and handling logic more deeply.
affects: All versions
Errors
Common errors & fixes
flake8: command not found
The `flake8` package, which is necessary to run `flake8-blind-except`, is not installed or not available in the current shell's PATH.
fix
Install `flake8` and `flake8-blind-except` together: `pip install flake8 flake8-blind-except`.
No B902 errors reported, even with blind `except:` statements in code.
`flake8-blind-except` might not be installed, or your `flake8` configuration is explicitly ignoring `B902` or selecting a limited set of checks that exclude it.
fix
First, verify installation with `pip show flake8-blind-except`. Then, check your `flake8` configuration files (e.g., `pyproject.toml`, `setup.cfg`, `.flake8`) for `ignore = B902` or `select = ...` directives.
ModuleNotFoundError: No module named 'setuptools'
Older versions of `flake8-blind-except` (prior to 0.2.1) incorrectly listed `setuptools` in `install_requires`, which could lead to installation issues in some minimal environments.
fix
Upgrade `flake8-blind-except` to version 0.2.1 or newer: `pip install --upgrade flake8-blind-except`.
Upgrade
Version history
0.2.1latest on PyPI · released Mar 18, 2022
Audit
Dependencies
flake8requiredThis library is a plugin for flake8 and requires flake8 to be installed to function.
Agent activity
4 hits · last 30 days
node
4
Resources
flake8-blind-except — pip install flake8-blind-except · libregistry