Metadata-Version: 2.1
Name: flake8-raise
Version: 0.0.4
Summary: A flake8 plugin that finds that finds improvements for raise statements.
Home-page: https://github.com/jdufresne/flake8-raise
Author: Jon Dufresne
Author-email: jon.dufresne@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Framework :: Flake8
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.5
Description-Content-Type: text/x-rst
Requires-Dist: flake8

============
flake8-raise
============

A `flake8 <https://flake8.readthedocs.io/>`_ plugin that finds improvements for
raise statements.

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

Install using ``pip``:

.. code-block:: sh

    $ pip install flake8-raise

When installed, the plugin will automatically be used by ``flake8``. To check
it is installed correctly, run ``flake8 --version`` and look in the list of
installed plugins:

.. code-block:: sh

    $ flake8 --version
    3.7.9 (flake8-raise: 0.0.4, mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.8.1 on Linux

Rules
-----

==== ====
Code Rule
==== ====
R100 raise in except handler without from.
R101 Use bare raise in except handler.
==== ====

Examples
--------

R100 raise in except handler without from.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: py

    try:
        foo["bar"]
    except KeyError:
        raise MyException

Will result in the error:

.. code-block:: text

    R100 raise in except handler without from.

To fix, change to:

.. code-block:: py

    try:
        foo['bar']
    except KeyError as e:
        raise MyException from e

R101 Use bare raise in except handler.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: py

    try:
        foo["bar"]
    except KeyError as e:
        raise e

Will result in the error:

.. code-block:: text

    R101 Use bare raise in except handler.

To fix, change to:

.. code-block:: py

    try:
        foo['bar']
    except KeyError:
        raise


