Skip to content

Commit 618fed2

Browse files
hugovkAA-Turner
authored andcommitted
Meta: Run check-peps.py in pre-commit (python#4071)
Co-authored-by: Adam Turner <[email protected]>
1 parent c296583 commit 618fed2

File tree

2 files changed

+13
-151
lines changed

2 files changed

+13
-151
lines changed

Diff for: .github/workflows/lint.yml

-14
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,3 @@ jobs:
3333
uses: pre-commit/[email protected]
3434
with:
3535
extra_args: --all-files --hook-stage manual codespell || true
36-
37-
check-peps:
38-
name: Run check-peps
39-
runs-on: ubuntu-latest
40-
41-
steps:
42-
- uses: actions/checkout@v4
43-
- name: Set up Python 3
44-
uses: actions/setup-python@v5
45-
with:
46-
python-version: "3"
47-
48-
- name: Run check-peps
49-
run: python check-peps.py --detailed

Diff for: .pre-commit-config.yaml

+13-137
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ minimum_pre_commit_version: '2.8.2'
66
default_language_version:
77
python: python3
88

9-
default_stages: [commit]
9+
default_stages: [pre-commit]
1010

1111

1212
repos:
1313
# General file checks and fixers
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.6.0
15+
rev: v5.0.0
1616
hooks:
1717
- id: mixed-line-ending
1818
name: "Normalize mixed line endings"
@@ -43,7 +43,7 @@ repos:
4343
name: "Check YAML"
4444

4545
- repo: https://github.com/psf/black-pre-commit-mirror
46-
rev: 24.4.2
46+
rev: 24.10.0
4747
hooks:
4848
- id: black
4949
name: "Format with Black"
@@ -53,7 +53,7 @@ repos:
5353
files: '^(peps/conf\.py|pep_sphinx_extensions/tests/.*)$'
5454

5555
- repo: https://github.com/astral-sh/ruff-pre-commit
56-
rev: v0.5.1
56+
rev: v0.7.0
5757
hooks:
5858
- id: ruff
5959
name: "Lint with Ruff"
@@ -62,13 +62,13 @@ repos:
6262
files: '^pep_sphinx_extensions/tests/'
6363

6464
- repo: https://github.com/tox-dev/tox-ini-fmt
65-
rev: 1.3.1
65+
rev: 1.4.1
6666
hooks:
6767
- id: tox-ini-fmt
6868
name: "Format tox.ini"
6969

7070
- repo: https://github.com/sphinx-contrib/sphinx-lint
71-
rev: v0.9.1
71+
rev: v1.0.0
7272
hooks:
7373
- id: sphinx-lint
7474
name: "Sphinx lint"
@@ -98,134 +98,10 @@ repos:
9898
# Local checks for PEP headers and more
9999
- repo: local
100100
hooks:
101-
# # Hook to run "check-peps.py"
102-
# - id: "check-peps"
103-
# name: "Check PEPs for metadata and content enforcement"
104-
# entry: "python check-peps.py"
105-
# language: "system"
106-
# files: "^pep-\d{4}\.(rst|txt)$"
107-
# require_serial: true
108-
109-
- id: check-required-headers
110-
name: "PEPs must have all required headers"
111-
language: pygrep
112-
entry: '(?-m:^PEP:(?=[\s\S]*\nTitle:)(?=[\s\S]*\nAuthor:)(?=[\s\S]*\nStatus:)(?=[\s\S]*\nType:)(?=[\s\S]*\nCreated:))'
113-
args: ['--negate', '--multiline']
114-
files: '^peps/pep-\d+\.rst$'
115-
116-
- id: check-header-order
117-
name: "PEP header order must follow PEP 12"
118-
language: pygrep
119-
entry: '^PEP:[^\n]+\nTitle:[^\n]+\n(Version:[^\n]+\n)?(Last-Modified:[^\n]+\n)?Author:[^\n]+\n( +\S[^\n]+\n)*(Sponsor:[^\n]+\n)?((PEP|BDFL)-Delegate:[^\n]*\n)?(Discussions-To:[^\n]*\n)?Status:[^\n]+\nType:[^\n]+\n(Topic:[^\n]+\n)?(Content-Type:[^\n]+\n)?(Requires:[^\n]+\n)?Created:[^\n]+\n(Python-Version:[^\n]*\n)?(Post-History:[^\n]*\n( +\S[^\n]*\n)*)?(Replaces:[^\n]+\n)?(Superseded-By:[^\n]+\n)?(Resolution:[^\n]*\n)?\n'
120-
args: ['--negate', '--multiline']
121-
files: '^peps/pep-\d+\.rst$'
122-
123-
- id: validate-pep-number
124-
name: "'PEP' header must be a number 1-9999"
125-
language: pygrep
126-
entry: '(?-m:^PEP:(?:(?! +(0|[1-9][0-9]{0,3})\n)))'
127-
args: ['--multiline']
128-
files: '^peps/pep-\d+\.rst$'
129-
130-
- id: validate-title
131-
name: "'Title' must be 1-79 characters"
132-
language: pygrep
133-
entry: '(?<=\n)Title:(?:(?! +\S.{1,78}\n(?=[A-Z])))'
134-
args: ['--multiline']
135-
files: '^peps/pep-\d+\.rst$'
136-
exclude: '^peps/pep-(0499)\.rst$'
137-
138-
- id: validate-author
139-
name: "'Author' must be list of 'Name <[email protected]>, ...'"
140-
language: pygrep
141-
entry: '(?<=\n)Author:(?:(?!((( +|\n {1,8})[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?)(,|(?=\n[^ ])))+\n(?=[A-Z])))'
142-
args: ["--multiline"]
143-
files: '^peps/pep-\d+\.rst$'
144-
145-
- id: validate-sponsor
146-
name: "'Sponsor' must have format 'Name <[email protected]>'"
147-
language: pygrep
148-
entry: '^Sponsor:(?: (?! *[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?$))'
149-
files: '^peps/pep-\d+\.rst$'
150-
151-
- id: validate-delegate
152-
name: "'Delegate' must have format 'Name <[email protected]>'"
153-
language: pygrep
154-
entry: '^(PEP|BDFL)-Delegate: (?:(?! *[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?$))'
155-
files: '^peps/pep-\d+\.rst$'
156-
exclude: '^peps/pep-(0451)\.rst$'
157-
158-
- id: validate-discussions-to
159-
name: "'Discussions-To' must be a thread URL"
160-
language: pygrep
161-
entry: '^Discussions-To: (?:(?!([\w\-]+@(python\.org|googlegroups\.com))|https://((discuss\.python\.org/t/([\w\-]+/)?\d+/?)|(mail\.python\.org/pipermail/[\w\-]+/\d{4}-[A-Za-z]+/[A-Za-z0-9]+\.html)|(mail\.python\.org/archives/list/[\w\-]+@python\.org/thread/[A-Za-z0-9]+/?))$))'
162-
files: '^peps/pep-\d+\.rst$'
163-
164-
- id: validate-status
165-
name: "'Status' must be a valid PEP status"
166-
language: pygrep
167-
entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))'
168-
files: '^peps/pep-\d+\.rst$'
169-
170-
- id: validate-type
171-
name: "'Type' must be a valid PEP type"
172-
language: pygrep
173-
entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))'
174-
files: '^peps/pep-\d+\.rst$'
175-
176-
- id: validate-topic
177-
name: "'Topic' must be for a valid sub-index"
178-
language: pygrep
179-
entry: '^Topic:(?:(?! +(Governance|Packaging|Typing|Release)(, (Governance|Packaging|Typing|Release))*$))'
180-
files: '^peps/pep-\d+\.rst$'
181-
182-
- id: validate-content-type
183-
name: "'Content-Type' must be 'text/x-rst'"
184-
language: pygrep
185-
entry: '^Content-Type:(?:(?! +text/x-rst$))'
186-
files: '^peps/pep-\d+\.rst$'
187-
188-
- id: validate-pep-references
189-
name: "`Requires`/`Replaces`/`Superseded-By` must be 'NNN' PEP IDs"
190-
language: pygrep
191-
entry: '^(Requires|Replaces|Superseded-By):(?:(?! *( (0|[1-9][0-9]{0,3})(,|$))+$))'
192-
files: '^peps/pep-\d+\.rst$'
193-
194-
- id: validate-created
195-
name: "'Created' must be a 'DD-mmm-YYYY' date"
196-
language: pygrep
197-
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])$))'
198-
files: '^peps/pep-\d+\.rst$'
199-
200-
- id: validate-python-version
201-
name: "'Python-Version' must be a 'X.Y[.Z]` version"
202-
language: pygrep
203-
entry: '^Python-Version:(?:(?! *( [1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?(,|$))+$))'
204-
files: '^peps/pep-\d+\.rst$'
205-
206-
- id: validate-post-history
207-
name: "'Post-History' must be '`DD-mmm-YYYY <Thread URL>`__, ...'"
208-
language: pygrep
209-
entry: '(?<=\n)Post-History:(?:(?! ?\n|((( +|\n {1,14})(([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])|`([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]) <https://((discuss\.python\.org/t/([\w\-]+/)?\d+(?:/\d+/|/?))|(mail\.python\.org/pipermail/[\w\-]+/\d{4}-[A-Za-z]+/[A-Za-z0-9]+\.html)|(mail\.python\.org/archives/list/[\w\-]+@python\.org/thread/[A-Za-z0-9]+/?(#[A-Za-z0-9]+)?))>`__)(,|(?=\n[^ ])))+\n(?=[A-Z\n]))))'
210-
args: [--multiline]
211-
files: '^peps/pep-\d+\.rst$'
212-
213-
- id: validate-resolution
214-
name: "'Resolution' must be a direct thread/message URL or '`DD-mmm-YYYY <URL>`__'"
215-
language: pygrep
216-
entry: '(?<!\n\n)(?<=\n)Resolution: (?:(?!https://((discuss\.python\.org/t/([\w\-]+/)?\d+(/\d+)?/?)|(mail\.python\.org/pipermail/[\w\-]+/\d{4}-[A-Za-z]+/[A-Za-z0-9]+\.html)|(mail\.python\.org/archives/list/[\w\-]+@python\.org/(message|thread)/[A-Za-z0-9]+/?(#[A-Za-z0-9]+)?)))|`([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]) <(?:(?!https://((discuss\.python\.org/t/([\w\-]+/)?\d+(/\d+)?/?)|(mail\.python\.org/pipermail/[\w\-]+/\d{4}-[A-Za-z]+/[A-Za-z0-9]+\.html)|(mail\.python\.org/archives/list/[\w\-]+@python\.org/(message|thread)/[A-Za-z0-9]+/?(#[A-Za-z0-9]+)?)))>`__))\n'
217-
args: ['--multiline']
218-
files: '^peps/pep-\d+\.rst$'
219-
220-
- id: check-direct-pep-links
221-
name: "Check that PEPs aren't linked directly"
222-
language: pygrep
223-
entry: '(dev/peps|peps\.python\.org)/pep-\d+'
224-
files: '^peps/pep-\d+\.rst$'
225-
exclude: '^peps/pep-(0009|0287|0676|0684|8001)\.rst$'
226-
227-
- id: check-direct-rfc-links
228-
name: "Check that RFCs aren't linked directly"
229-
language: pygrep
230-
entry: '(rfc-editor\.org|ietf\.org)/[\.\-_\?\&\#\w/]*[Rr][Ff][Cc][\-_]?\d+'
231-
types: ['rst']
101+
# Hook to run "check-peps.py"
102+
- id: "check-peps"
103+
name: "Check PEPs for metadata and content enforcement"
104+
entry: "python check-peps.py"
105+
language: "python"
106+
files: '^peps/pep-\d{4}\.rst$'
107+
require_serial: true

0 commit comments

Comments
 (0)