-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.pre-commit-config.yaml
148 lines (143 loc) · 4.47 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
minimum_pre_commit_version: 2.15.0
exclude: ^LICENSES/|\.(html|csv|svg)$
default_stages: [
commit,
merge-commit,
push,
prepare-commit-msg,
commit-msg,
post-checkout,
post-commit,
post-merge,
post-rewrite
]
ci:
autofix_prs: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
exclude: \.txt$
stages: [commit, merge-commit, push, prepare-commit-msg, commit-msg,
post-checkout, post-commit, post-merge, post-rewrite]
- id: trailing-whitespace
stages: [commit, merge-commit, push, prepare-commit-msg, commit-msg,
post-checkout, post-commit, post-merge, post-rewrite]
- id: mixed-line-ending
stages: [commit, merge-commit, push, prepare-commit-msg, commit-msg,
post-checkout, post-commit, post-merge, post-rewrite]
args: ["--fix=lf"]
exclude: (tox.ini|.*.bat)
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
stages: [commit]
args: [--py3-plus]
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
stages: [commit]
additional_dependencies: [black==23.3.0]
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.286
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/terrencepreilly/darglint.git
rev: v1.8.1
hooks:
- id: darglint
exclude: ^(src/xleapp/plugins|tests/)
- repo: local
hooks:
- id: pyright
# note: assumes python env is setup and activated
name: pyright
entry: pyright
language: node
pass_filenames: false
types: [python]
stages: [manual]
additional_dependencies: &pyright_dependencies
- id: pyright_reportGeneralTypeIssues
# note: assumes python env is setup and activated
name: pyright reportGeneralTypeIssues
entry: pyright --skipunannotated -p pyright_reportGeneralTypeIssues.json --level warning
language: node
pass_filenames: false
types: [python]
stages: [manual]
additional_dependencies: *pyright_dependencies
# NOTE: we make `black` a local hook because if it's installed from
# PyPI (rather than from source) then it'll run twice as fast thanks to mypyc
- id: black
name: black
description: "Black: The uncompromising Python code formatter"
entry: black
language: python
require_serial: true
types_or: [python, pyi]
additional_dependencies: [black==23.3.0]
- id: unwanted-patterns
name: Unwanted patterns
language: pygrep
entry: |
(?x)
# outdated annotation syntax, missing error codes
\#\ type:\ (?!ignore)
|\#\ type:\s?ignore(?!\[)
# foo._class__ instead of type(foo)
|\.__class__
# imports from collections.abc instead of `from collections import abc`
|from\ collections\.abc\ import
# Incorrect code-block / IPython directives
|\.\.\ code-block\ ::
|\.\.\ ipython\ ::
# directive should not have a space before ::
|\.\.\ \w+\ ::
# Check for deprecated messages without sphinx directive
|(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
# {foo!r} instead of {repr(foo)}
|!r}
# exec
|[^a-zA-Z0-9_]exec\(
types_or: [python, cython, rst]
exclude: ^docs/source/development/code_style\.rst # contains examples of patterns to avoid
- id: unwanted-patterns-in-tests
name: Unwanted patterns in tests
language: pygrep
entry: |
(?x)
# pytest.xfail instead of pytest.mark.xfail
pytest\.xfail
# No direct imports from conftest
|conftest\ import
|import\ conftest
# unittest.mock (use pytest builtin monkeypatch fixture instead)
|(unittest(\.| import )mock|mock\.Mock\(\)|mock\.patch)
# pytest raises without context
|\s\ pytest.raises
# pytest.warns (use tm.assert_produces_warning instead)
|pytest\.warns
files: ^tests/
types_or: [python, cython, rst]
- id: no-return-exception
name: Use raise instead of return for exceptions
language: pygrep
entry: 'return [A-Za-z]+(Error|Exit|Interrupt|Exception|Iteration)'
files: ^src/
types: [python]
exclude: ^tests/
- id: pytest
name: Check pytest unit tests pass
entry: pytest tests/
pass_filenames: false
language: system
types: [python]
stages: [push]