forked from python/peps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
148 lines (137 loc) · 5.1 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
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
minimum_pre_commit_version: '2.8.2'
default_language_version:
python: python3
default_stages: [commit]
repos:
# General file checks and fixers
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: mixed-line-ending
name: "Normalize mixed line endings"
args: [--fix=lf]
- id: fix-byte-order-marker
name: "Remove Unicode BOM"
- id: file-contents-sorter
name: "Sort codespell ignore list"
files: '.codespell/ignore-words.txt'
- id: check-case-conflict
name: "Check for case conflicts"
- id: check-merge-conflict
name: "Check for merge conflict markers"
- id: check-executables-have-shebangs
name: "Check that executables have shebangs"
- id: check-shebang-scripts-are-executable
name: "Check that shebangs are executable"
- id: check-vcs-permalinks
name: "Check that VCS links are permalinks"
- id: check-ast
name: "Check Python AST"
- id: check-json
name: "Check JSON"
- id: check-toml
name: "Check TOML"
- id: check-yaml
name: "Check YAML"
# RST checks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: rst-backticks
name: "Check RST: No single backticks"
- id: rst-inline-touching-normal
name: "Check RST: No backticks touching text"
files: '^pep-\d+\.txt|\.rst$'
types: [text]
- id: rst-directive-colons
name: "Check RST: 2 colons after directives"
files: '^pep-\d+\.txt|\.rst$'
types: [text]
# Manual codespell check
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
name: "Check for common misspellings in text files"
stages: [manual]
# Local checks for PEP headers and more
- repo: local
hooks:
- id: check-no-tabs
name: "Check tabs not used in PEPs"
language: pygrep
entry: '\t'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: check-required-fields
name: "Check PEPs have all required fields"
language: pygrep
entry: '(?-m:^PEP:(?=[\s\S]*\nTitle:)(?=[\s\S]*\nAuthor:)(?=[\s\S]*\nStatus:)(?=[\s\S]*\nType:)(?=[\s\S]*\nContent-Type:)(?=[\s\S]*\nCreated:))'
args: ['--negate', '--multiline']
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-pep-number
name: "Validate PEP number field"
language: pygrep
entry: '(?-m:^PEP:(?:(?! +(0|[1-9][0-9]{0,3})\n)))'
args: ['--multiline']
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-status
name: "Validate PEP 'Status' field"
language: pygrep
entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-type
name: "Validate PEP 'Type' field"
language: pygrep
entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-content-type
name: "Validate PEP 'Content-Type' field"
language: pygrep
entry: '^Content-Type:(?:(?! +text\/x-rst$))'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-pep-references
name: "Validate PEP reference fields"
language: pygrep
entry: '^(Requires|Replaces|Superseded-By):(?:(?! +( ?(0|[1-9][0-9]{0,3}),?)+$))'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-created
name: "Validate PEP 'Created' field"
language: pygrep
entry: '^Created:(?:(?! +([0-2][0-9]|(3[01]))-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(199[0-9]|20[0-9][0-9])( \([^()]+\))?$))'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-python-version
name: "Validate PEP 'Python-Version' field"
language: pygrep
entry: '^Python-Version:(?:(?! +( ?[1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?\??,?)+( \([^()]+\))?$))'
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: validate-resolution
name: "Validate PEP 'Resolution' field"
language: pygrep
entry: '(?<!\n\n)^Resolution: (?:(?!(https:\/\/\S*|:pep:`[a-zA-Z\d \-<>#]*?`)\n))'
args: ['--multiline']
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: check-direct-pep-links
name: "Check that PEPs aren't linked directly"
language: pygrep
entry: '(dev/peps|peps\.python\.org)/pep-\d+'
files: '^pep-\d+\.(rst|txt)$'
exclude: '^pep-(0009|0287|0676|8001)\.(rst|txt)$'
types: [text]
- id: check-direct-rfc-links
name: "Check that RFCs aren't linked directly"
language: pygrep
entry: '(rfc-editor\.org|ietf\.org)/[\.\-_\?\&\#\w/]*[Rr][Ff][Cc][\-_]?\d+'
files: '\.(rst|txt)$'
types: [text]