![]() * Add release tool - Add tool for release managers to use to generate commits - I'm trying to only use stdlib so we have no depdencies ... - Default is to change date strings in hard coded documentation files + CHANGES.md - I write directly to files cause we have SCM to fix any screw ups ... - We hackily convert calver to ints to sort (all for better ideas here) - If we hit a ValueError we just set to 0 for sorting - This is alhpa + beta release we can safely ignore these days - Add new CI to only run release unittests in 3.12 only on all platforms - Update release docs - Checked with `mypy --strict` + ensure we are `black --preview` formatted :D Tests: - Run it to generate template PR - `python3.12 release.py --debug --add-changes-template` - Run it to cleanup CHANGE.md + change version in specified doc files ``` crl-m1:black cooper$ python3.12 release.py -d [2023-10-23 23:39:38,414] INFO: Current version detected to be 23.10.1 (release.py:221) [2023-10-23 23:39:38,414] INFO: Next version will be 23.10.2 (release.py:222) [2023-10-23 23:39:38,414] INFO: Cleaning up /Users/cooper/repos/black/CHANGES.md (release.py:127) [2023-10-23 23:39:38,416] DEBUG: Finished Cleaning up /Users/cooper/repos/black/CHANGES.md (release.py:147) [2023-10-23 23:39:38,416] INFO: Updating black version to 23.10.2 in /Users/cooper/repos/black/docs/integrations/source_version_control.md (release.py:173) [2023-10-23 23:39:38,416] DEBUG: Finished updating black version to 23.10.2 in /Users/cooper/repos/black/docs/integrations/source_version_control.md (release.py:185) [2023-10-23 23:39:38,416] INFO: Updating black version to 23.10.2 in /Users/cooper/repos/black/docs/usage_and_configuration/the_basics.md (release.py:173) [2023-10-23 23:39:38,417] DEBUG: Finished updating black version to 23.10.2 in /Users/cooper/repos/black/docs/usage_and_configuration/the_basics.md (release.py:185) ``` - Add tests around some key logic * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix lints + add git to release CI - Remove black + mypy as linting already runs it ... - Ignore delete param to TemporaryDirectory as we can't set mypy to 3.12 :D * Only run CI on linux/ubuntu for now * Add lots of debug printing + directly run unitests (not via coverage) * Overloading __str__ is bad on a TestCase * Add more logging around git tag * Print where git is in a step * Rollback creating a fake black repo as we were not using it - I did plan to but I can't get it working on GitHub actions * Do a deep checkout * Add noqa for E701,E761 ... maybe we need this in our flake8 config now? * Fix action to have correct workflow yaml to action on - Also add fix to not double run when we push directly to psf/black * All jelle suggestions - Fix bug missing lines ending with --> in CHANGES.md to delete ... - Update ci to run out of scripts dir too - Update test_tuple_calver --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> |
||
---|---|---|
.github | ||
action | ||
autoload | ||
docs | ||
gallery | ||
plugin | ||
profiling | ||
scripts | ||
src | ||
tests | ||
.flake8 | ||
.git_archival.txt | ||
.gitattributes | ||
.gitignore | ||
.pre-commit-config.yaml | ||
.pre-commit-hooks.yaml | ||
.prettierrc.yaml | ||
.readthedocs.yaml | ||
action.yml | ||
AUTHORS.md | ||
CHANGES.md | ||
CITATION.cff | ||
CONTRIBUTING.md | ||
Dockerfile | ||
LICENSE | ||
pyproject.toml | ||
README.md | ||
SECURITY.md | ||
test_requirements.txt | ||
tox.ini |
The Uncompromising Code Formatter
“Any color you like.”
Black is the uncompromising Python code formatter. By using it, you agree to cede
control over minutiae of hand-formatting. In return, Black gives you speed,
determinism, and freedom from pycodestyle
nagging about formatting. You will save time
and mental energy for more important matters.
Blackened code looks the same regardless of the project you're reading. Formatting becomes transparent after a while and you can focus on the content instead.
Black makes code review faster by producing the smallest diffs possible.
Try it out now using the Black Playground. Watch the PyCon 2019 talk to learn more.
Read the documentation on ReadTheDocs!
Installation and usage
Installation
Black can be installed by running pip install black
. It requires Python 3.8+ to run.
If you want to format Jupyter Notebooks, install with pip install "black[jupyter]"
.
If you can't wait for the latest hotness and want to install from GitHub, use:
pip install git+https://github.com/psf/black
Usage
To get started right away with sensible defaults:
black {source_file_or_directory}
You can run Black as a package if running it as a script doesn't work:
python -m black {source_file_or_directory}
Further information can be found in our docs:
Black is already successfully used by many projects, small and big. Black has a comprehensive test suite, with efficient parallel tests, and our own auto formatting and parallel Continuous Integration runner. Now that we have become stable, you should not expect large formatting changes in the future. Stylistic changes will mostly be responses to bug reports and support for new Python syntax. For more information please refer to The Black Code Style.
Also, as a safety measure which slows down processing, Black will check that the
reformatted code still produces a valid AST that is effectively equivalent to the
original (see the
Pragmatism
section for details). If you're feeling confident, use --fast
.
The Black code style
Black is a PEP 8 compliant opinionated formatter. Black reformats entire files in place. Style configuration options are deliberately limited and rarely added. It doesn't take previous formatting into account (see Pragmatism for exceptions).
Our documentation covers the current Black code style, but planned changes to it are also documented. They're both worth taking a look at:
Changes to the Black code style are bound by the Stability Policy:
Please refer to this document before submitting an issue. What seems like a bug might be intended behaviour.
Pragmatism
Early versions of Black used to be absolutist in some respects. They took after its initial author. This was fine at the time as it made the implementation simpler and there were not many users anyway. Not many edge cases were reported. As a mature tool, Black does make some exceptions to rules it otherwise holds.
Please refer to this document before submitting an issue just like with the document above. What seems like a bug might be intended behaviour.
Configuration
Black is able to read project-specific default values for its command line options
from a pyproject.toml
file. This is especially useful for specifying custom
--include
and --exclude
/--force-exclude
/--extend-exclude
patterns for your
project.
You can find more details in our documentation:
And if you're looking for more general configuration documentation:
Pro-tip: If you're asking yourself "Do I need to configure anything?" the answer is "No". Black is all about sensible defaults. Applying those defaults will have your code in compliance with many other Black formatted projects.
Used by
The following notable open-source projects trust Black with enforcing a consistent code style: pytest, tox, Pyramid, Django, Django Channels, Hypothesis, attrs, SQLAlchemy, Poetry, PyPA applications (Warehouse, Bandersnatch, Pipenv, virtualenv), pandas, Pillow, Twisted, LocalStack, every Datadog Agent Integration, Home Assistant, Zulip, Kedro, OpenOA, FLORIS, ORBIT, WOMBAT, and many more.
The following organizations use Black: Facebook, Dropbox, KeepTruckin, Lyft, Mozilla, Quora, Duolingo, QuantumBlack, Tesla, Archer Aviation.
Are we missing anyone? Let us know.
Testimonials
Mike Bayer, author of SQLAlchemy
:
I can't think of any single tool in my entire programming career that has given me a bigger productivity increase by its introduction. I can now do refactorings in about 1% of the keystrokes that it would have taken me previously when we had no way for code to format itself.
Dusty Phillips, writer:
Black is opinionated so you don't have to be.
Hynek Schlawack, creator of attrs
, core developer of
Twisted and CPython:
An auto-formatter that doesn't suck is all I want for Xmas!
Carl Meyer, Django core developer:
At least the name is good.
Kenneth Reitz, creator of requests
and pipenv
:
This vastly improves the formatting of our code. Thanks a ton!
Show your style
Use the badge in your project's README.md:
[](https://github.com/psf/black)
Using the badge in README.rst:
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
License
MIT
Contributing
Welcome! Happy to see you willing to make the project better. You can get started by reading this:
You can also take a look at the rest of the contributing docs or talk with the developers:
Change log
The log has become rather long. It moved to its own file.
See CHANGES.
Authors
The author list is quite long nowadays, so it lives in its own file.
See AUTHORS.md
Code of Conduct
Everyone participating in the Black project, and in particular in the issue tracker, pull requests, and social media activity, is expected to treat other people with respect and more generally to follow the guidelines articulated in the Python Community Code of Conduct.
At the same time, humor is encouraged. In fact, basic familiarity with Monty Python's Flying Circus is expected. We are not savages.
And if you really need to slap somebody, do it with a fish while dancing.