flake8-blind-except

0.2.1 · active · verified Fri Apr 17

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.

Common errors

Warnings

Install

Quickstart

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

view raw JSON →