<p align="center">
<a href="https://travis-ci.com/psf/black"><img alt="Build Status" src="https://travis-ci.com/psf/black.svg?branch=master"></a>
+<a href="https://github.com/psf/black/actions"><img alt="Actions Status" src="https://github.com/psf/black/workflows/Test/badge.svg"></a>
<a href="https://black.readthedocs.io/en/stable/?badge=stable"><img alt="Documentation Status" src="https://readthedocs.org/projects/black/badge/?version=stable"></a>
<a href="https://coveralls.io/github/psf/black?branch=master"><img alt="Coverage Status" src="https://coveralls.io/repos/github/psf/black/badge.svg?branch=master"></a>
<a href="https://github.com/psf/black/blob/master/LICENSE"><img alt="License: MIT" src="https://black.readthedocs.io/en/stable/_static/license.svg"></a>
-<a href="https://pypi.org/project/black/"><img alt="PyPI" src="https://black.readthedocs.io/en/stable/_static/pypi.svg"></a>
+<a href="https://pypi.org/project/black/"><img alt="PyPI" src="https://img.shields.io/pypi/v/black"></a>
<a href="https://pepy.tech/project/black"><img alt="Downloads" src="https://pepy.tech/badge/black"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>
j = [1,
2,
- 3,
+ 3
]
# out:
max-line-length = 80
...
select = C,E,F,W,B,B950
-ignore = E501,W503,E203
+ignore = E203, E501, W503
```
-You'll find _Black_'s own .flake8 config file is configured like this. If you're curious
-about the reasoning behind B950,
+You'll find _Black_'s own .flake8 config file is configured like this. Explanation of
+why W503 and E203 are disabled can be found further in this documentation. And if you're
+curious about the reasoning behind B950,
[Bugbear's documentation](https://github.com/PyCQA/flake8-bugbear#opinionated-warnings)
explains it. The tl;dr is "it's like highway speed limits, we won't bother you if you
overdo it by a few km/h".
+**If you're looking for a minimal, black-compatible flake8 configuration:**
+
+```ini
+[flake8]
+max-line-length = 88
+extend-ignore = E203
+```
+
### Empty lines
_Black_ avoids spurious vertical whitespace. This is in the spirit of PEP 8 which says
```
**How to get Vim with Python 3.6?** On Ubuntu 17.10 Vim comes with Python 3.6 by
-default. On macOS with Homebrew run: `brew install vim --with-python3`. When building
-Vim from source, use: `./configure --enable-python3interp=yes`. There's many guides
-online how to do this.
+default. On macOS with Homebrew run: `brew install vim`. When building Vim from source,
+use: `./configure --enable-python3interp=yes`. There's many guides online how to do
+this.
### Visual Studio Code
}
```
+### Thonny
+
+Use [Thonny-black-code-format](https://github.com/Franccisco/thonny-black-code-format).
+
### Other editors
Other editors will require external contributions.
a set of comma-separated Python versions, optionally prefixed with `py`. For example,
to request code that is compatible with Python 3.5 and 3.6, set the header to
`py3.5,py3.6`.
+- `X-Diff`: corresponds to the `--diff` command line flag. If present, a diff of the
+ formats will be output.
If any of these headers are set to invalid values, `blackd` returns a `HTTP 400` error
response, mentioning the name of the problematic header in the message body.
Avoid using `args` in the hook. Instead, store necessary configuration in
`pyproject.toml` so that editors and command-line usage of Black all behave consistently
-for your project. See _Black_'s own [pyproject.toml](/pyproject.toml) for an example.
+for your project. See _Black_'s own
+[pyproject.toml](https://github.com/psf/black/blob/master/pyproject.toml) for an
+example.
If you're already using Python 3.7, switch the `language_version` accordingly. Finally,
`stable` is a tag that is pinned to the latest release on PyPI. If you'd rather run on
The following notable open-source projects trust _Black_ with enforcing a consistent
code style: pytest, tox, Pyramid, Django Channels, Hypothesis, attrs, SQLAlchemy,
Poetry, PyPA applications (Warehouse, Pipenv, virtualenv), pandas, Pillow, every Datadog
-Agent Integration.
+Agent Integration, Home Assistant.
Are we missing anyone? Let us know.
## Change Log
-### unreleased
+### 19.10b0
+
+- added support for PEP 572 assignment expressions (#711)
+
+- added support for PEP 570 positional-only arguments (#943)
+
+- added support for async generators (#593)
+
+- added support for pre-splitting collections by putting an explicit trailing comma
+ inside (#826)
- added `black -c` as a way to format code passed from the command line (#761)
- fixed feature detection for trailing commas in function definitions and call sites
(#763)
-- _Black_ can now format async generators (#593)
+- `# fmt: off`/`# fmt: on` comment pairs placed multiple times within the same block of
+ code now behave correctly (#1005)
- _Black_ no longer crashes on Windows machines with more than 61 cores (#838)
- _Black_ no longer crashes on `from` ... `import` blocks with comments (#829)
+- _Black_ no longer crashes on Python 3.7 on some platform configurations (#494)
+
+- _Black_ no longer fails on comments in from-imports (#671)
+
+- _Black_ no longer fails when the file starts with a backslash (#922)
+
+- _Black_ no longer merges regular comments with type comments (#1027)
+
+- _Black_ no longer splits long lines that contain type comments (#997)
+
- removed unnecessary parentheses around `yield` expressions (#834)
- added parentheses around long tuples in unpacking assignments (#832)
+- added parentheses around complex powers when they are prefixed by a unary operator
+ (#646)
+
- fixed bug that led _Black_ format some code with a line length target of 1 (#762)
- _Black_ no longer introduces quotes in f-string subexpressions on string boundaries
- if _Black_ puts parenthesis around a single expression, it moves comments to the
wrapped expression instead of after the brackets (#872)
-- _Black_ is now able to format Python code that uses assignment expressions (`:=` as
- described in PEP-572) (#935)
-
-- _Black_ is now able to format Python code that uses positional-only arguments (`/` as
- described in PEP-570) (#946)
-
- `blackd` now returns the version of _Black_ in the response headers (#1013)
+- `blackd` can now output the diff of formats on source code when the `X-Diff` header is
+ provided (#969)
+
### 19.3b0
- new option `--target-version` to control which Python versions _Black_-formatted code
Multiple contributions by:
+- [Abdur-Rahmaan Janhangeer](mailto:cryptolabour@gmail.com)
+- [Adam Johnson](mailto:me@adamj.eu)
+- [Alexander Huynh](mailto:github@grande.coffee)
+- [Andrew Thorp](mailto:andrew.thorp.dev@gmail.com)
+- [Andrey](mailto:dyuuus@yandex.ru)
+- [Andy Freeland](mailto:andy@andyfreeland.net)
- [Anthony Sottile](mailto:asottile@umich.edu)
+- [Arjaan Buijk](mailto:arjaan.buijk@gmail.com)
- [Artem Malyshev](mailto:proofit404@gmail.com)
+- [Asger Hautop Drewsen](mailto:asgerdrewsen@gmail.com)
+- [Augie Fackler](mailto:raf@durin42.com)
+- [Aviskar KC](mailto:aviskarkc10@gmail.com)
- [Benjamin Woodruff](mailto:github@benjam.info)
+- [Brandt Bucher](mailto:brandtbucher@gmail.com)
+- Charles Reid
- [Christian Heimes](mailto:christian@python.org)
+- [Chuck Wooters](mailto:chuck.wooters@microsoft.com)
+- [Daniel Hahler](mailto:github@thequod.de)
- [Daniel M. Capella](mailto:polycitizen@gmail.com)
+- Daniele Esposti
+- dylanjblack
- [Eli Treuherz](mailto:eli@treuherz.com)
+- [Florent Thiery](mailto:fthiery@gmail.com)
- hauntsaninja
- Hugo van Kemenade
- [Ivan Katanić](mailto:ivan.katanic@gmail.com)
- [Jason Fried](mailto:me@jasonfried.info)
+- [jgirardet](mailto:ijkl@netc.fr)
+- [Joe Antonakakis](mailto:jma353@cornell.edu)
+- [Jon Dufresne](mailto:jon.dufresne@gmail.com)
- [Jonas Obrist](mailto:ojiidotch@gmail.com)
+- [Josh Bode](mailto:joshbode@fastmail.com)
+- [Juan Luis Cano Rodríguez](mailto:hello@juanlu.space)
+- [Katie McLaughlin](mailto:katie@glasnt.com)
+- Lawrence Chan
+- [Linus Groh](mailto:mail@linusgroh.de)
- [Luka Sterbic](mailto:luka.sterbic@gmail.com)
+- Mariatta
+- [Matt VanEseltine](mailto:vaneseltine@gmail.com)
+- [Michael Flaxman](mailto:michael.flaxman@gmail.com)
+- [Michael J. Sullivan](mailto:sully@msully.net)
+- [Michael McClimon](mailto:michael@mcclimon.org)
- [Miguel Gaiowski](mailto:miggaiowski@gmail.com)
+- [Mike](mailto:roshi@fedoraproject.org)
+- [Min ho Kim](mailto:minho42@gmail.com)
- [Miroslav Shubernetskiy](mailto:miroslav@miki725.com)
- [Neraste](mailto:neraste.herr10@gmail.com)
+- [Ofek Lev](mailto:ofekmeister@gmail.com)
- [Osaetin Daniel](mailto:osaetindaniel@gmail.com)
+- [Pablo Galindo](mailto:Pablogsal@gmail.com)
- [Peter Bengtsson](mailto:mail@peterbe.com)
+- pmacosta
+- [Rishikesh Jha](mailto:rishijha424@gmail.com)
- [Stavros Korokithakis](mailto:hi@stavros.io)
+- [Stephen Rosen](mailto:sirosen@globus.org)
- [Sunil Kapil](mailto:snlkapil@gmail.com)
+- [Thom Lu](mailto:thomas.c.lu@gmail.com)
+- [Tom Christie](mailto:tom@tomchristie.com)
+- [Tzu-ping Chung](mailto:uranusjr@gmail.com)
- [Utsav Shah](mailto:ukshah2@illinois.edu)
+- vezeli
- [Vishwas B Sharma](mailto:sharma.vishwas88@gmail.com)
-- [Chuck Wooters](mailto:chuck.wooters@microsoft.com)
+- [Yngve Høiseth](mailto:yngve@hoiseth.net)
+- [Yurii Karabas](mailto:1998uriyyo@gmail.com)