black repo: https://github.com/ambv/black

Goal

black the uncompromising Python code formatter

By using Black, 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.

Black makes code review faster by producing the smallest diffs possible.

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.

Example

 1---
 2
 3# .pre-commit-config.yaml
 4# ========================
 5#
 6# pre-commit clean
 7# pre-commit install
 8# pre-commit install-hooks
 9#
10# precommit hooks installation
11#
12# - pre-commit autoupdate
13#
14# - pre-commit run black
15#
16# continuous integration
17# ======================
18#
19# - pre-commit run --all-files
20#
21
22repos:
23  - repo: https://github.com/pre-commit/pre-commit-hooks
24    rev: v4.6.0
25    hooks:
26    - id: trailing-whitespace
27    - id: end-of-file-fixer
28    - id: check-yaml
29    - id: check-json
30    - id: fix-encoding-pragma
31      args: ['--remove']
32    - id: forbid-new-submodules
33    - id: mixed-line-ending
34      args: ['--fix=lf']
35      description: Forces to replace line ending by the UNIX 'lf' character.
36    # - id: pretty-format-json
37    #  args: ['--no-sort-keys']
38    - id: check-added-large-files
39      args: ['--maxkb=500']
40    - id: no-commit-to-branch
41      args: [--branch, staging]
42
43
44  - repo: https://github.com/asottile/reorder_python_imports
45    rev: v3.12.0
46    hooks:
47      - id: reorder-python-imports
make check_all
pre-commit run --all-files
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...............................................................Passed
Check for added large files..............................................Passed
black....................................................................Failed
hookid: black

Files were modified by this hook. Additional output:

reformatted /home/pvergain/projects/tuto_git/conf.py
reformatted /home/pvergain/projects/tuto_git/tools/pre-commit/hooks/pre-commit
All done! ✨ 🍰 ✨
2 files reformatted.