generated from pragmaticindustries/python-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
157 lines (142 loc) · 4.19 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_stages: [commit]
repos:
# These meta hooks check the pre-commit configuration itself.
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
# Commitizen enforces semantic and conventional commit messages.
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.20.4
hooks:
- id: commitizen
name: Check conventional commit message
stages: [commit-msg]
# Sort imports.
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: Sort import statements
# Add Black code formatters.
- repo: https://github.com/ambv/black
rev: 21.12b0
hooks:
- id: black
name: Format code
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.0
hooks:
- id: blacken-docs
name: Format code in docstrings
args: [--line-length, '120']
additional_dependencies: [black==21.12b0]
# Upgrade and rewrite Python idioms.
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
name: Upgrade code idioms
files: ^src/django_app_tree/|^tests/|setup.py
args: [--py39-plus]
# Similar to pylint, with a few more/different checks.
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
name: Enforce PEP8 style guide
files: ^src/django_app_tree/|^tests/|setup.py
additional_dependencies: [flake8-builtins==1.5.3, flake8-docstrings==1.6.0, flake8-rst-docstrings==0.2.3, pep8-naming==0.12.1]
# Run Pylint from the local repo to make sure venv packages
# specified in setup.py are available.
- repo: local
hooks:
- id: pylint
name: Check lint
entry: pylint
language: python
files: ^src/django_app_tree/|^tests/|setup.py
args: []
# Type-check all Python code.
- repo: local
hooks:
- id: mypy
name: Check typing annotations
entry: mypy
language: python
files: ^src/django_app_tree/|^tests/|setup.py
args: [--config-file, mypy.ini]
# Enable a whole bunch of useful helper hooks, too.
# See https://pre-commit.com/hooks.html for more hooks.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: debug-statements
- id: end-of-file-fixer
stages: [commit]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
stages: [commit]
- id: detect-private-key
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: check-yaml
- id: check-toml
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
# Check the reStructured Text files that make up
# this package's documentation.
# Commenting this out because https://github.com/Lucas-C/pre-commit-hooks-markup/issues/13
# - repo: https://github.com/Lucas-C/pre-commit-hooks-markup
# rev: v1.0.1
# hooks:
# - id: rst-linter
# Check and prettify the configuration files.
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.2.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix]
# Commenting this out because https://github.com/pappasam/toml-sort/issues/11
# - id: pretty-format-toml
# args: [--autofix]
# Make sure that the package's MANIFEST.in file works.
- repo: https://github.com/mgedmin/check-manifest
rev: '0.47'
hooks:
- id: check-manifest
name: Check package manifest
# Check the tox.ini configuration.
# Commenting this out because https://github.com/tox-dev/tox-ini-fmt/issues/42
# - repo: https://github.com/tox-dev/tox-ini-fmt
# rev: 0.3.0
# hooks:
# - id: tox-ini-fmt
# On push to the remote, run the unit tests.
- repo: local
hooks:
- id: pytest
name: Run unit tests
# entry: python -W always::DeprecationWarning -m pytest
entry: pytest
language: python
verbose: true
always_run: true
pass_filenames: false
stages: [push]