[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#992366: ITP: flake8-blind-except -- A flake8 extension that checks for blind, catch-all except: and except Exception: statements.



Package: wnpp
Severity: wishlist
Owner: Jose Luis Rivero <jrivero@osrfoundation.org>

* Package name    : flake8-blind-except
  Version         : 0.2.0
  Upstream Author : Elijah Andrews 
* URL             : https://github.com/elijahandrews/flake8-blind-except
* License         : MIT
  Programming Lang: python
  Description     : A flake8 extension that checks for blind, catch-all except: and except Exception: statements.


As of pycodestyle 2.1.0, "E722 do not use bare except, specify exception
instead" is built-in. However, bare Exception and BaseException are
still allowed. This extension flags them as B902.

Using except without explicitly specifying which exceptions to catch is
generally considered bad practice, since it catches system signals like
SIGINT. You probably want to handle system interrupts differently than
exceptions occuring in your code.

It's also usually better style to have many small try-except blocks
catching specific exceptions instead of a giant try: block with a
catch-all except: at the bottom. It's also nicer to your fellow
programmers to be a bit more specific about what exceptions they can
expect in specific parts of the code, and what the proper course of
action is when they occur.


Reply to: