Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35722df

Browse files
authored
Max line length with bugbear (psf#3731)
* Make phrasing for flake8 users more concise max-line-length should be 80 with flake8-bugbear Fixes psf#3716 * Re-add rationale and an explanation for disabling E203 * Run pre-commit
1 parent 688f78d commit 35722df

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

docs/the_black_code_style/current_style.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,33 +160,35 @@ harder to work with line lengths exceeding 100 characters. It also adversely aff
160160
side-by-side diff review on typical screen resolutions. Long lines also make it harder
161161
to present code neatly in documentation or talk slides.
162162

163-
If you're using Flake8, you can bump `max-line-length` to 88 and mostly forget about it.
164-
However, it's better if you use [Bugbear](https://github.com/PyCQA/flake8-bugbear)'s
165-
B950 warning instead of E501, and bump the max line length to 88 (or the `--line-length`
166-
you used for black), which will align more with black's _"try to respect
167-
`--line-length`, but don't become crazy if you can't"_. You'd do it like this:
168-
169-
```ini
170-
[flake8]
171-
max-line-length = 88
172-
...
173-
select = C,E,F,W,B,B950
174-
extend-ignore = E203, E501
175-
```
163+
#### Flake8
176164

177-
Explanation of why E203 is disabled can be found further in this documentation. And if
178-
you're curious about the reasoning behind B950,
179-
[Bugbear's documentation](https://github.com/PyCQA/flake8-bugbear#opinionated-warnings)
180-
explains it. The tl;dr is "it's like highway speed limits, we won't bother you if you
181-
overdo it by a few km/h".
165+
If you use Flake8, you have a few options:
182166

183-
**If you're looking for a minimal, black-compatible flake8 configuration:**
167+
1. Recommended is using [Bugbear](https://github.com/PyCQA/flake8-bugbear) and enabling
168+
its B950 check instead of using Flake8's E501, because it aligns with Black's 10%
169+
rule. Install Bugbear and use the following config:
184170

185-
```ini
186-
[flake8]
187-
max-line-length = 88
188-
extend-ignore = E203
189-
```
171+
```ini
172+
[flake8]
173+
max-line-length = 80
174+
...
175+
select = C,E,F,W,B,B950
176+
extend-ignore = E203, E501
177+
```
178+
179+
The rationale for E950 is explained in
180+
[Bugbear's documentation](https://github.com/PyCQA/flake8-bugbear#opinionated-warnings).
181+
182+
2. For a minimally compatible config:
183+
184+
```ini
185+
[flake8]
186+
max-line-length = 88
187+
extend-ignore = E203
188+
```
189+
190+
An explanation of why E203 is disabled can be found in the [Slices section](#slices) of
191+
this page.
190192

191193
### Empty lines
192194

0 commit comments

Comments
 (0)