Skip to main content

A flake8 extension that checks for blind except: statements

Project description

flake8-blind-except
===================

A flake8 extension that checks for blind, catch-all ``except:`` statements.

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.

An example of code that will fail this check is:

.. code-block:: python

try:
something_scary()
except:
everybody_panic()

However, the following code is valid:

.. code-block:: python

try:
something_terrifying()
except TerrifyingException:
dont_panic()

Installation
------------

If you don't already have it, install ``flake8``::

$ pip install flake8

Then, install the extension::

$ pip install flake8-blind-except

Usage
-----

Run the following to verify that the plugin has been installed correctly::

$ flake8 --version
2.0 (pep8: 1.4.6, flake8-blind-except: 0.1.0, pyflakes: 0.7.3)

Now, when you run ``flake8``, the plugin will automatically be used.

When a blind except is found, ``flake8`` will output::

B901 blind except: statement



Changes
------

0.1.1 - 2016-06-27
``````````````````
* ``pep8`` was renamed to ``pycodestyle`` in its 2.0 release. Compatibility update for this change

0.1.0 - 2014-02-07
``````````````````
* Initial release

Notes
-----

I've tested this package with flake8 2.6.2 and Python 2.7.3. It is untested (but likely compatible) with other software versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8-blind-except-0.1.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_blind_except-0.1.1-py2.7.egg (3.3 kB view details)

Uploaded Egg

File details

Details for the file flake8-blind-except-0.1.1.tar.gz.

File metadata

File hashes

Hashes for flake8-blind-except-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aca3356633825544cec51997260fe31a8f24a1a2795ce8e81696b9916745e599
MD5 bd74ca16e060b3cf1dd69d3f27aadae7
BLAKE2b-256 fff2ab635e6e420e78c94eab50cd3f53abd3ec27e411793e50b14f29edbb9f0b

See more details on using hashes here.

File details

Details for the file flake8_blind_except-0.1.1-py2.7.egg.

File metadata

File hashes

Hashes for flake8_blind_except-0.1.1-py2.7.egg
Algorithm Hash digest
SHA256 0d7d1adb4cabf2268d6eebb815a7a5014bcb7e8419f7a74339c46d0b8847b858
MD5 e8bac36467b587367df16c0a1a9a03fa
BLAKE2b-256 ae8caef0d2419897fe9f916bd60a01cfdbe8d6cb6d79278b16d55ff1c3b24771

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page