A flake8 plugin that finds improvements for raise statements.
Installation
Install using pip:
$ 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:
$ flake8 --version
3.7.9 (flake8-raise: 0.0.5, 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 |
R102 |
unnecessary parentheses on raised exception |
Examples
R100 raise in except handler without from
try:
foo["bar"]
except KeyError:
raise MyException
Will result in the error:
R100 raise in except handler without from.
To fix, change to:
try:
foo['bar']
except KeyError as e:
raise MyException from e
R101 use bare raise in except handler
try:
foo["bar"]
except KeyError as e:
raise e
Will result in the error:
R101 Use bare raise in except handler.
To fix, change to:
try:
foo['bar']
except KeyError:
raise
R102 unnecessary parentheses on raised exception
raise TypeError()
Will result in the error:
R102 unnecessary parentheses on raised exception
To fix, change to:
raise TypeError
Metadata
Release files for flake8-raise 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8-raise-0.0.5.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_raise-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / flake8-raise-0.0.5.tar.gz
| Download URL | flake8-raise-0.0.5.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a9890e16b851402d9b0d4fafe6c34890eab73835a2c2079c3850a25be575623
|
|
BLAKE2b-256 checksum How to use checksums |
453d0211d7fb77b3bc6c49495575de4dd07b2ca6fc90a6784bca6097ec980cb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.2 pkginfo/1.4.2 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.6
|
Release files / flake8_raise-0.0.5-py3-none-any.whl
| Download URL | flake8_raise-0.0.5-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df26e5c542a58c8f8786d978e18ad7e54126a0ef5c6241c35dafaca7e2bbb808
|
|
BLAKE2b-256 checksum How to use checksums |
dab7b8edb1ae5c517b8d3cd693129daab16282c5a4b4fc6ad4522cedc29eba61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.2 pkginfo/1.4.2 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.6
|