blacken docs repo: https://github.com/asottile/blacken-docs ¶
Goal ¶
Run black on python code blocks in documentation files.
(tuto_git) git commit . -m "Add black docs"
[INFO] Initializing environment for https://github.com/asottile/blacken-docs.
[INFO] Initializing environment for https://github.com/asottile/blacken-docs:black==19.3b0.
[INFO] Installing environment for https://github.com/asottile/blacken-docs.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
blacken-docs.............................................................Failed
hookid: blacken-docs
Traceback (most recent call last):
File "/home/pvergain/.cache/pre-commit/repo2jffwdx1/py_env-python3/bin/blacken-docs", line 10, in <module>
sys.exit(main())
File "/home/pvergain/.cache/pre-commit/repo2jffwdx1/py_env-python3/lib/python3.7/site-packages/blacken_docs.py", line 109, in main
'mode': black.FileMode.AUTO_DETECT,
AttributeError: type object 'FileMode' has no attribute 'AUTO_DETECT'
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