77[ ![ black] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/psf/black )
88
99Flake8-plus is a plugin for [ Flake8] ( https://github.com/PyCQA/flake8 ) that detects
10- incorrect amounts of vertical whitespace before the first toplevel ` import ` statement
11- and before ` return ` statements. The plugin can be configured to expect any number of
12- blank lines. By default, the plugin expects no blank lines before both ` import ` and
13- ` return ` .
10+ incorrect amounts of vertical whitespace before the first toplevel ` import ` statement,
11+ before ` return ` statements and before ` except ` . The plugin can be configured to expect
12+ any number of blank lines. By default, the plugin expects no blank lines before both the
13+ ` import ` and ` return ` statements, and the ` except ` keyword .
1414
1515## Installation
1616
@@ -31,11 +31,11 @@ $ flake8 --version
3131## Configuration
3232
3333You can set the required number of blank lines before the first ` import ` as well as the
34- number of blank lines required before a ` return ` . This can be done from the command
35- line:
34+ number of blank lines required before a ` return ` and before ` except ` . This can be done
35+ from the command line:
3636
3737``` shell
38- $ flake8 --blanks-before-imports 1 --blanks-before-return 1
38+ $ flake8 --blanks-before-imports 1 --blanks-before-return 1 --blanks-before-except 1
3939```
4040
4141Or from one of the ` setup.cfg ` , ` tox.ini ` , or ` .flake8 ` files:
@@ -44,6 +44,7 @@ Or from one of the `setup.cfg`, `tox.ini`, or `.flake8` files:
4444[flake8]
4545blanks-before-imports =1
4646blanks-before-return =1
47+ blanks-before-except =1
4748```
4849
4950## Why no blank lines?
@@ -86,9 +87,27 @@ October 2022).
8687Since zero blank lines is the style used most frequently, Flake8-plus uses that as that
8788as the default.
8889
90+ ### Before ` except `
91+
92+ Neither Black, Flake8 nor Pylint enforces a specific number of blank lines preceding
93+ ` except ` . However, they all use zero blank lines more frequently than they use any other
94+ number of blanks. The table below shows the frequency of the number of blank lines
95+ before an ` except ` statement in the code bases for Black, Flake8 and Pylint (as of
96+ October 2022).
97+
98+ | Package | Total ` except ` s | 0 blanks | 1 blank | 2 blanks | Folder |
99+ | ------- | --------------: | -------: | ------: | -------: | ------------- |
100+ | Black | 71 | 64 | 7 | 0 | ` src ` |
101+ | Flake8 | 26 | 26 | 0 | 0 | ` src/flake8/ ` |
102+ | Pylint | 285 | 283 | 2 | 0 | ` pylint ` |
103+
104+ Since zero blank lines is the style used most frequently, Flake8-plus uses that as that
105+ as the default.
106+
89107## Reported problems
90108
91109| Code | Description |
92110| ------ | ----------------------------------------------------------- |
93111| PLU001 | "expected {} blank lines before first import, found {}" |
94112| PLU002 | "expected {} blank lines before return statement, found {}" |
113+ | PLU003 | "expected {} blank lines before except, found {}" |
0 commit comments