black/docs
Jairo Llopis d62d677ca2
Recommend B950 + 88 char limit instead of 80 (#2050)
[The section about line length][1] was contradictory.

On one side, it said:

> Black will try to respect that [line length limit]. However, sometimes it won't be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

So black doesn't guarantee that your code is formatted at 88 chars, even when configured with `--line-length=88` (default). Black uses this limit as a "hint" more than a "rule".

OTOH, it also said:

> If you're using Flake8, you can bump max-line-length to 88 and forget about it. Alternatively, use Bugbear's B950 warning instead of E501 and keep the max line length at 80 which you are probably already using.

But that's not true. You can't "forget about it" because Black sometimes won't respect the limit. Both E501 at 88 and B950 at 80 behave the same: linter error at 89+ length. So, if Black happens to decide that a line of code is better at 90 characters that some other fancy style, you land on a unlucky situation where both tools will fight.

So, AFAICS, the best way to align flake8 and black is to:

1. Use flake8-bugbear
2. Enable B950
3. Disable E501
4. Set `max-line-length = 88`

This way, we also tell flake8 that 88 limit is a "hint" and not a "rule". The real rule will be 88 + 10%. If black decides that a line fits better in 97 characters than in 88 + some formatting, _that_ probably means your code has a real problem.

To avoid further confusion, I change the official recommendation here.

[1]: e82bb8d8b8 (opinionated-warnings)
2021-03-18 08:14:15 -07:00
..
_static As long as it's black (#1893) 2020-12-31 09:03:39 -08:00
compatible_configs fix #1917 (#1918) 2021-01-11 08:21:14 -08:00
reference Fixup: update function name in docs to match source (#1997) 2021-02-22 07:46:38 -08:00
authors.md Indicate that a final newline was added in --diff (#1897) (#1897) 2021-02-21 22:43:23 -08:00
black_primer.md Upgrade docs to Sphinx 3+ and add doc build test (#1613) 2020-08-21 00:06:41 +02:00
blackd.md Add --skip-magic-trailing-comma (#1824) 2021-01-17 16:59:06 -08:00
change_log.md Add --extend-exclude parameter (#2005) 2021-03-01 14:07:36 -08:00
compatible_configs.md Update link pointing to how-black-wraps-lines (#1925) 2021-01-14 15:57:45 -08:00
conf.py Make doc generation a little smarter, update doc sections 2020-08-24 14:42:17 +02:00
contributing_to_black.md Update Contributing Docs (#1915) 2021-01-13 15:17:30 -08:00
editor_integration.md Add ALE (#1753) 2021-03-05 20:22:19 -08:00
github_actions.md Update Contributing Docs (#1915) 2021-01-13 15:17:30 -08:00
ignoring_unmodified_files.md Fix dealing with generated files in docs 2020-08-21 16:45:30 +02:00
index.rst Upgrade docs to Sphinx 3+ and add doc build test (#1613) 2020-08-21 00:06:41 +02:00
installation_and_usage.md Add --extend-exclude parameter (#2005) 2021-03-01 14:07:36 -08:00
make.bat add sphinx docs skeleton (#71) 2018-03-23 14:27:04 -07:00
Makefile add sphinx docs skeleton (#71) 2018-03-23 14:27:04 -07:00
pyproject_toml.md Add --extend-exclude parameter (#2005) 2021-03-01 14:07:36 -08:00
requirements.txt Upgrade docs to Sphinx 3+ and add doc build test (#1613) 2020-08-21 00:06:41 +02:00
show_your_style.md Fix dealing with generated files in docs 2020-08-21 16:45:30 +02:00
the_black_code_style.md Recommend B950 + 88 char limit instead of 80 (#2050) 2021-03-18 08:14:15 -07:00
version_control_integration.md Update Contributing Docs (#1915) 2021-01-13 15:17:30 -08:00