Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ __pycache__
*~
*env
.coverage
.idea
.tox
.vscode
*.swp
/build
/peps/topic
/package
/peps/topic
/venv
97 changes: 38 additions & 59 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@ repos:
hooks:
- id: rst-backticks
name: "Check RST: No single backticks"
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: rst-inline-touching-normal
name: "Check RST: No backticks touching text"
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: rst-directive-colons
name: "Check RST: 2 colons after directives"
files: '^peps/pep-\d+\.rst$'
types: [text]

# Manual codespell check
- repo: https://github.com/codespell-project/codespell
Expand All @@ -101,152 +97,135 @@ repos:
# 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: '^peps/pep-\d+\.rst$'
types: [text]

- id: check-required-headers
name: "PEPs must have all required headers"
language: pygrep
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']
args:
- '--negate'
- '--multiline'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: check-header-order
name: "PEP header order must follow PEP 12"
language: pygrep
language: 'pygrep'
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'
args: ['--negate', '--multiline']
args:
- '--negate'
- '--multiline'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-pep-number
name: "'PEP' header must be a number 1-9999"
language: pygrep
language: 'pygrep'
entry: '(?-m:^PEP:(?:(?! +(0|[1-9][0-9]{0,3})\n)))'
args: ['--multiline']
args:
- '--multiline'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-title
name: "'Title' must be 1-79 characters"
language: pygrep
language: 'pygrep'
entry: '(?<=\n)Title:(?:(?! +\S.{1,78}\n(?=[A-Z])))'
args: ['--multiline']
args:
- '--multiline'
files: '^peps/pep-\d+\.rst$'
exclude: '^peps/pep-(0499)\.rst$'
types: [text]

- id: validate-author
name: "'Author' must be list of 'Name <[email protected]>, ...'"
language: pygrep
language: 'pygrep'
entry: '(?<=\n)Author:(?:(?!((( +|\n {1,8})[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?)(,|(?=\n[^ ])))+\n(?=[A-Z])))'
args: [--multiline]
args:
- '--multiline'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-sponsor
name: "'Sponsor' must have format 'Name <[email protected]>'"
language: pygrep
language: 'pygrep'
entry: '^Sponsor:(?: (?! *[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-delegate
name: "'Delegate' must have format 'Name <[email protected]>'"
language: pygrep
language: 'pygrep'
entry: '^(PEP|BDFL)-Delegate: (?:(?! *[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?$))'
files: '^peps/pep-\d+\.rst$'
exclude: '^peps/pep-(0451)\.rst$'
types: [text]

- id: validate-discussions-to
name: "'Discussions-To' must be a thread URL"
language: pygrep
language: 'pygrep'
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]+/?))$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-status
name: "'Status' must be a valid PEP status"
language: pygrep
language: 'pygrep'
entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-type
name: "'Type' must be a valid PEP type"
language: pygrep
language: 'pygrep'
entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-topic
name: "'Topic' must be for a valid sub-index"
language: pygrep
language: 'pygrep'
entry: '^Topic:(?:(?! +(Governance|Packaging|Typing|Release)(, (Governance|Packaging|Typing|Release))*$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-content-type
name: "'Content-Type' must be 'text/x-rst'"
language: pygrep
language: 'pygrep'
entry: '^Content-Type:(?:(?! +text/x-rst$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-pep-references
name: "`Requires`/`Replaces`/`Superseded-By` must be 'NNN' PEP IDs"
language: pygrep
language: 'pygrep'
entry: '^(Requires|Replaces|Superseded-By):(?:(?! *( (0|[1-9][0-9]{0,3})(,|$))+$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-created
name: "'Created' must be a 'DD-mmm-YYYY' date"
language: pygrep
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: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-python-version
name: "'Python-Version' must be a 'X.Y[.Z]` version"
language: pygrep
language: 'pygrep'
entry: '^Python-Version:(?:(?! *( [1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?(,|$))+$))'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-post-history
name: "'Post-History' must be '`DD-mmm-YYYY <Thread URL>`__, ...'"
language: pygrep
language: 'pygrep'
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]))))'
args: [--multiline]
args:
- '--multiline'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: validate-resolution
name: "'Resolution' must be a direct thread/message URL"
language: pygrep
language: 'pygrep'
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]+)?))\n))'
args: ['--multiline']
args:
- '--multiline'
files: '^peps/pep-\d+\.rst$'
types: [text]

- id: check-direct-pep-links
name: "Check that PEPs aren't linked directly"
language: pygrep
language: 'pygrep'
entry: '(dev/peps|peps\.python\.org)/pep-\d+'
files: '^peps/pep-\d+\.rst$'
exclude: '^peps/pep-(0009|0287|0676|0684|8001)\.rst$'
types: [text]

- id: check-direct-rfc-links
name: "Check that RFCs aren't linked directly"
language: pygrep
language: 'pygrep'
entry: '(rfc-editor\.org|ietf\.org)/[\.\-_\?\&\#\w/]*[Rr][Ff][Cc][\-_]?\d+'
files: '\.rst$'
types: [text]
types: ['rst']