Skip to content

Commit df0aeee

Browse files
authored
Formalise style preference description (#2818)
Closes #1256: I reworded our style docs to be more explicit about the style we're aiming for and how it is changed (or isn't).
1 parent 4ce049d commit df0aeee

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

docs/the_black_code_style/current_style.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
## Code style
44

5-
_Black_ reformats entire files in place. Style configuration options are deliberately
6-
limited and rarely added. It doesn't take previous formatting into account, except for
7-
the magic trailing comma and preserving newlines. It doesn't reformat blocks that start
8-
with `# fmt: off` and end with `# fmt: on`, or lines that ends with `# fmt: skip`.
5+
_Black_ aims for consistency, generality, readability and reducing git diffs. Similar
6+
language constructs are formatted with similar rules. Style configuration options are
7+
deliberately limited and rarely added. Previous formatting is taken into account as
8+
little as possible, with rare exceptions like the magic trailing comma. The coding style
9+
used by _Black_ can be viewed as a strict subset of PEP 8.
10+
11+
_Black_ reformats entire files in place. It doesn't reformat blocks that start with
12+
`# fmt: off` and end with `# fmt: on`, or lines that ends with `# fmt: skip`.
913
`# fmt: on/off` have to be on the same level of indentation. It also recognizes
1014
[YAPF](https://github.com/google/yapf)'s block comments to the same effect, as a
1115
courtesy for straddling code.
@@ -18,8 +22,7 @@ running `black --preview`.
1822

1923
_Black_ ignores previous formatting and applies uniform horizontal and vertical
2024
whitespace to your code. The rules for horizontal whitespace can be summarized as: do
21-
whatever makes `pycodestyle` happy. The coding style used by _Black_ can be viewed as a
22-
strict subset of PEP 8.
25+
whatever makes `pycodestyle` happy.
2326

2427
As for vertical whitespace, _Black_ tries to render one full expression or simple
2528
statement per line. If this fits the allotted line length, great.

docs/the_black_code_style/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ The Black Code Style
1212
While keeping the style unchanged throughout releases has always been a goal,
1313
the *Black* code style isn't set in stone. It evolves to accommodate for new features
1414
in the Python language and, occasionally, in response to user feedback.
15+
Large-scale style preferences presented in :doc:`current_style` are very unlikely to
16+
change, but minor style aspects and details might change according to the stability
17+
policy presented below. Ongoing style considerations are tracked on GitHub with the
18+
`design <https://github.com/psf/black/labels/T%3A%20design>`_ issue label.
1519

1620
Stability Policy
1721
----------------

0 commit comments

Comments
 (0)