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

Skip to content

Commit 69705de

Browse files
docs: add clearer pyproject configuration guidance (psf#5026)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 35ea679 commit 69705de

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

docs/usage_and_configuration/the_basics.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ As the file extension suggests, `pyproject.toml` is a
513513
different tools. _Black_ is using the `[tool.black]` section. The option keys are the
514514
same as long names of options on the command line.
515515

516+
Most command-line options can be configured in `[tool.black]` by using their long name
517+
without the leading `--` (for example, `--line-length` becomes `line-length`). Options
518+
that cannot be configured in `pyproject.toml` are called out explicitly in the option
519+
reference above.
520+
516521
Note that you have to use single-quoted strings in TOML for regular expressions. It's
517522
the equivalent of r-strings in Python. Multiline strings are treated as verbose regular
518523
expressions by Black. Use `[ ]` to denote a significant space character.
@@ -538,6 +543,38 @@ extend-exclude = '''
538543

539544
</details>
540545

546+
<details>
547+
<summary>More complete <code>pyproject.toml</code> template</summary>
548+
549+
```toml
550+
[tool.black]
551+
line-length = 88
552+
target-version = ["py311"]
553+
required-version = "26"
554+
include = '\.pyi?$'
555+
556+
# Formatting behavior
557+
skip-string-normalization = false
558+
skip-magic-trailing-comma = false
559+
preview = false
560+
unstable = false
561+
562+
# File collection
563+
extend-exclude = '''
564+
(
565+
^/foo.py
566+
| .*_pb2.py
567+
)
568+
'''
569+
force-exclude = '''
570+
(
571+
^/generated/
572+
)
573+
'''
574+
```
575+
576+
</details>
577+
541578
### Lookup hierarchy
542579

543580
Command-line options have defaults that you can see in `--help`. A `pyproject.toml` can

0 commit comments

Comments
 (0)