@@ -134,78 +134,126 @@ profile = black
134134
135135</details >
136136
137- ### Flake8
137+ ### pycodestyle
138138
139- [ Flake8 ] ( https://pypi. org/p/flake8/ ) is a code linter. It warns you of syntax errors,
140- possible bugs, stylistic errors, etc. For the most part, Flake8 follows
139+ [ pycodestyle ] ( https://pycodestyle.pycqa. org/ ) is a code linter. It warns you of syntax
140+ errors, possible bugs, stylistic errors, etc. For the most part, pycodestyle follows
141141[ PEP 8] ( https://www.python.org/dev/peps/pep-0008/ ) when warning about stylistic errors.
142142There are a few deviations that cause incompatibilities with _ Black_ .
143143
144144#### Configuration
145145
146146```
147147max-line-length = 88
148- extend- ignore = E203, E704
148+ ignore = E203,E701
149149```
150150
151+ (labels/why-pycodestyle-warnings)=
152+
151153#### Why those options above?
152154
155+ ##### ` max-line-length `
156+
157+ As with isort, pycodestyle should be configured to allow lines up to the length limit of
158+ ` 88 ` , _ Black_ 's default.
159+
160+ ##### ` E203 `
161+
153162In some cases, as determined by PEP 8, _ Black_ will enforce an equal amount of
154- whitespace around slice operators. Due to this, Flake8 will raise
155- ` E203 whitespace before ':' ` warnings. Since this warning is not PEP 8 compliant, Flake8
156- should be configured to ignore it via ` extend-ignore = E203 ` .
163+ whitespace around slice operators. Due to this, pycodestyle will raise
164+ ` E203 whitespace before ':' ` warnings. Since this warning is not PEP 8 compliant, it
165+ should be disabled.
166+
167+ ##### ` E701 ` / ` E704 `
168+
169+ _ Black_ will collapse implementations of classes and functions consisting solely of ` .. `
170+ to a single line. This matches how such examples are formatted in PEP 8. It remains true
171+ that in all other cases Black will prevent multiple statements on the same line, in
172+ accordance with PEP 8 generally discouraging this.
173+
174+ However, ` pycodestyle ` does not mirror this logic and may raise
175+ ` E701 multiple statements on one line (colon) ` in this situation. Its
176+ disabled-by-default ` E704 multiple statements on one line (def) ` rule may also raise
177+ warnings and should not be enabled.
178+
179+ ##### ` W503 `
157180
158181When breaking a line, _ Black_ will break it before a binary operator. This is compliant
159182with PEP 8 as of
160183[ April 2016] ( https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b#diff-64ec08cc46db7540f18f2af46037f599 ) .
161184There's a disabled-by-default warning in Flake8 which goes against this PEP 8
162185recommendation called ` W503 line break before binary operator ` . It should not be enabled
163- in your configuration.
164-
165- Also, as like with isort, flake8 should be configured to allow lines up to the length
166- limit of ` 88 ` , _ Black_ 's default. This explains ` max-line-length = 88 ` .
186+ in your configuration. You can use its counterpart
187+ ` W504 line break after binary operator ` instead.
167188
168189#### Formats
169190
170191<details >
171- <summary >.flake8 </summary >
192+ <summary >setup.cfg, .pycodestyle, tox.ini </summary >
172193
173194``` ini
174- [flake8 ]
195+ [pycodestyle ]
175196max-line-length = 88
176- extend- ignore = E203, E704
197+ ignore = E203,E701
177198```
178199
179200</details >
180201
181- <details >
182- <summary >setup.cfg</summary >
202+ ### Flake8
183203
184- ``` ini
204+ [ Flake8] ( https://pypi.org/p/flake8/ ) is a wrapper around multiple linters, including
205+ pycodestyle. As such, it has many of the same issues.
206+
207+ #### Bugbear
208+
209+ It's recommended to use [ the Bugbear plugin] ( https://github.com/PyCQA/flake8-bugbear )
210+ and enable
211+ [ its B950 check] ( https://github.com/PyCQA/flake8-bugbear#opinionated-warnings#:~:text=you%20expect%20it.-,B950,-%3A%20Line%20too%20long )
212+ instead of using Flake8's E501, because it aligns with
213+ [ Black's 10% rule] ( labels/line-length ) .
214+
215+ Install Bugbear and use the following config:
216+
217+ ```
218+ [flake8]
219+ max-line-length = 80
220+ extend-select = B950
221+ extend-ignore = E203,E501,E701
222+ ```
223+
224+ #### Minimal Configuration
225+
226+ In cases where you can't or don't want to install Bugbear, you can use this minimally
227+ compatible config:
228+
229+ ```
185230[flake8]
186231max-line-length = 88
187- extend-ignore = E203, E704
232+ extend-ignore = E203,E701
188233```
189234
190- </details >
235+ #### Why those options above?
236+
237+ See [ the pycodestyle section] ( labels/why-pycodestyle-warnings ) above.
238+
239+ #### Formats
191240
192241<details >
193- <summary >tox.ini</summary >
242+ <summary >.flake8, setup.cfg, tox.ini</summary >
194243
195244``` ini
196245[flake8]
197246max-line-length = 88
198- extend-ignore = E203, E704
247+ extend-ignore = E203,E701
199248```
200249
201250</details >
202251
203252### Pylint
204253
205- [ Pylint] ( https://pypi.org/p/pylint/ ) is also a code linter like Flake8. It has the same
206- checks as flake8 and more. In particular, it has more formatting checks regarding style
207- conventions like variable naming. With so many checks, Pylint is bound to have some
208- mixed feelings about _ Black_ 's formatting style.
254+ [ Pylint] ( https://pypi.org/p/pylint/ ) is also a code linter like Flake8. It has many of
255+ the same checks as Flake8 and more. It particularly has more formatting checks regarding
256+ style conventions like variable naming.
209257
210258#### Configuration
211259
@@ -252,35 +300,3 @@ max-line-length = "88"
252300```
253301
254302</details >
255-
256- ### pycodestyle
257-
258- [ pycodestyle] ( https://pycodestyle.pycqa.org/ ) is also a code linter like Flake8.
259-
260- #### Configuration
261-
262- ```
263- max-line-length = 88
264- ignore = E203
265- ```
266-
267- #### Why those options above?
268-
269- pycodestyle should be configured to only complain about lines that surpass ` 88 `
270- characters via ` max_line_length = 88 ` .
271-
272- See
273- [ Why are Flake8’s E203 and W503 violated?] ( https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated )
274-
275- #### Formats
276-
277- <details >
278- <summary >setup.cfg</summary >
279-
280- ``` cfg
281- [pycodestyle]
282- ignore = E203
283- max_line_length = 88
284- ```
285-
286- </details >
0 commit comments