2022-01-31 21:49:58 -05:00
|
|
|
# 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]
|
|
|
|
|
|
|
|
|
2021-02-08 10:20:51 -05:00
|
|
|
repos:
|
2022-01-31 21:49:58 -05:00
|
|
|
# General file checks and fixers
|
2021-03-22 15:29:08 -04:00
|
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
2024-07-17 01:04:03 -04:00
|
|
|
rev: v4.6.0
|
2021-03-22 15:29:08 -04:00
|
|
|
hooks:
|
2022-01-24 18:40:15 -05:00
|
|
|
- id: mixed-line-ending
|
2022-01-31 21:49:58 -05:00
|
|
|
name: "Normalize mixed line endings"
|
2022-01-24 18:40:15 -05:00
|
|
|
args: [--fix=lf]
|
2022-01-31 21:49:58 -05:00
|
|
|
- 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"
|
|
|
|
|
2022-04-20 05:53:08 -04:00
|
|
|
# - id: check-ast
|
|
|
|
# name: "Check Python AST"
|
2022-01-31 21:49:58 -05:00
|
|
|
- id: check-json
|
|
|
|
name: "Check JSON"
|
|
|
|
- id: check-toml
|
|
|
|
name: "Check TOML"
|
|
|
|
- id: check-yaml
|
|
|
|
name: "Check YAML"
|
2021-03-22 15:29:08 -04:00
|
|
|
|
2023-12-12 12:06:18 -05:00
|
|
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
2024-07-17 01:04:03 -04:00
|
|
|
rev: 24.4.2
|
2022-04-26 15:07:20 -04:00
|
|
|
hooks:
|
|
|
|
- id: black
|
|
|
|
name: "Format with Black"
|
|
|
|
args:
|
|
|
|
- '--target-version=py39'
|
|
|
|
- '--target-version=py310'
|
2024-07-17 01:04:03 -04:00
|
|
|
files: '^(peps/conf\.py|pep_sphinx_extensions/tests/.*)$'
|
2022-04-26 15:07:20 -04:00
|
|
|
|
2023-09-10 11:04:40 -04:00
|
|
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
2024-07-17 01:04:03 -04:00
|
|
|
rev: v0.5.1
|
2023-09-10 11:04:40 -04:00
|
|
|
hooks:
|
|
|
|
- id: ruff
|
|
|
|
name: "Lint with Ruff"
|
|
|
|
args:
|
|
|
|
- '--exit-non-zero-on-fix'
|
|
|
|
files: '^pep_sphinx_extensions/tests/'
|
|
|
|
|
2022-04-26 15:07:20 -04:00
|
|
|
- repo: https://github.com/tox-dev/tox-ini-fmt
|
2023-08-16 01:07:57 -04:00
|
|
|
rev: 1.3.1
|
2022-04-26 15:07:20 -04:00
|
|
|
hooks:
|
|
|
|
- id: tox-ini-fmt
|
|
|
|
name: "Format tox.ini"
|
|
|
|
|
2022-10-06 15:14:32 -04:00
|
|
|
- repo: https://github.com/sphinx-contrib/sphinx-lint
|
2023-12-12 12:06:18 -05:00
|
|
|
rev: v0.9.1
|
2022-10-06 15:14:32 -04:00
|
|
|
hooks:
|
|
|
|
- id: sphinx-lint
|
|
|
|
name: "Sphinx lint"
|
2022-10-14 01:01:49 -04:00
|
|
|
args: ["--disable=trailing-whitespace"]
|
2022-10-06 15:14:32 -04:00
|
|
|
|
2022-01-31 21:49:58 -05:00
|
|
|
# RST checks
|
2021-02-08 10:20:51 -05:00
|
|
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
2023-01-31 03:36:17 -05:00
|
|
|
rev: v1.10.0
|
2021-02-08 10:20:51 -05:00
|
|
|
hooks:
|
|
|
|
- id: rst-backticks
|
2022-01-31 21:49:58 -05:00
|
|
|
name: "Check RST: No single backticks"
|
2023-09-09 13:39:29 -04:00
|
|
|
|
2021-02-08 10:20:51 -05:00
|
|
|
- id: rst-inline-touching-normal
|
2022-01-31 21:49:58 -05:00
|
|
|
name: "Check RST: No backticks touching text"
|
2023-09-09 13:39:29 -04:00
|
|
|
|
2021-03-22 15:29:08 -04:00
|
|
|
- id: rst-directive-colons
|
2022-01-31 21:49:58 -05:00
|
|
|
name: "Check RST: 2 colons after directives"
|
2021-03-22 15:29:08 -04:00
|
|
|
|
2022-01-31 21:49:58 -05:00
|
|
|
# Manual codespell check
|
2022-01-24 18:40:15 -05:00
|
|
|
- repo: https://github.com/codespell-project/codespell
|
2024-07-17 01:04:03 -04:00
|
|
|
rev: v2.3.0
|
2022-01-24 18:40:15 -05:00
|
|
|
hooks:
|
|
|
|
- id: codespell
|
2022-01-31 21:49:58 -05:00
|
|
|
name: "Check for common misspellings in text files"
|
2022-01-24 18:40:15 -05:00
|
|
|
stages: [manual]
|
|
|
|
|
2022-01-31 21:49:58 -05:00
|
|
|
# Local checks for PEP headers and more
|
2021-03-22 15:29:08 -04:00
|
|
|
- repo: local
|
|
|
|
hooks:
|
2023-09-04 23:44:46 -04:00
|
|
|
# # Hook to run "check-peps.py"
|
|
|
|
# - id: "check-peps"
|
|
|
|
# name: "Check PEPs for metadata and content enforcement"
|
|
|
|
# entry: "python check-peps.py"
|
|
|
|
# language: "system"
|
|
|
|
# files: "^pep-\d{4}\.(rst|txt)$"
|
|
|
|
# require_serial: true
|
|
|
|
|
2022-10-16 00:09:24 -04:00
|
|
|
- id: check-required-headers
|
|
|
|
name: "PEPs must have all required headers"
|
2021-03-22 15:29:08 -04:00
|
|
|
language: pygrep
|
2023-09-27 21:00:23 -04:00
|
|
|
entry: '(?-m:^PEP:(?=[\s\S]*\nTitle:)(?=[\s\S]*\nAuthor:)(?=[\s\S]*\nStatus:)(?=[\s\S]*\nType:)(?=[\s\S]*\nCreated:))'
|
2021-03-23 10:55:26 -04:00
|
|
|
args: ['--negate', '--multiline']
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2022-10-16 00:09:24 -04:00
|
|
|
- id: check-header-order
|
|
|
|
name: "PEP header order must follow PEP 12"
|
|
|
|
language: pygrep
|
2023-09-27 21:00:23 -04:00
|
|
|
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'
|
2022-10-16 00:09:24 -04:00
|
|
|
args: ['--negate', '--multiline']
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-10-16 00:09:24 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-pep-number
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "'PEP' header must be a number 1-9999"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
|
|
|
entry: '(?-m:^PEP:(?:(?! +(0|[1-9][0-9]{0,3})\n)))'
|
|
|
|
args: ['--multiline']
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
|
|
|
- id: validate-title
|
|
|
|
name: "'Title' must be 1-79 characters"
|
|
|
|
language: pygrep
|
|
|
|
entry: '(?<=\n)Title:(?:(?! +\S.{1,78}\n(?=[A-Z])))'
|
|
|
|
args: ['--multiline']
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
|
|
|
exclude: '^peps/pep-(0499)\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
|
|
|
- id: validate-author
|
|
|
|
name: "'Author' must be list of 'Name <email@example.com>, ...'"
|
|
|
|
language: pygrep
|
|
|
|
entry: '(?<=\n)Author:(?:(?!((( +|\n {1,8})[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?)(,|(?=\n[^ ])))+\n(?=[A-Z])))'
|
2023-09-09 13:39:29 -04:00
|
|
|
args: ["--multiline"]
|
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
|
|
|
- id: validate-sponsor
|
|
|
|
name: "'Sponsor' must have format 'Name <email@example.com>'"
|
|
|
|
language: pygrep
|
|
|
|
entry: '^Sponsor:(?: (?! *[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
|
|
|
- id: validate-delegate
|
|
|
|
name: "'Delegate' must have format 'Name <email@example.com>'"
|
|
|
|
language: pygrep
|
|
|
|
entry: '^(PEP|BDFL)-Delegate: (?:(?! *[^!#$%&()*+,/:;<=>?@\[\\\]\^_`{|}~]+( <[\w!#$%&''*+\-/=?^_{|}~.]+(@| at )[\w\-.]+\.[A-Za-z0-9]+>)?$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
|
|
|
exclude: '^peps/pep-(0451)\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
|
|
|
- id: validate-discussions-to
|
|
|
|
name: "'Discussions-To' must be a thread URL"
|
|
|
|
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]+/?))$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-status
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "'Status' must be a valid PEP status"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
|
|
|
entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-type
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "'Type' must be a valid PEP type"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
|
|
|
entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2022-06-18 14:04:46 -04:00
|
|
|
- id: validate-topic
|
|
|
|
name: "'Topic' must be for a valid sub-index"
|
|
|
|
language: pygrep
|
2023-02-02 05:50:01 -05:00
|
|
|
entry: '^Topic:(?:(?! +(Governance|Packaging|Typing|Release)(, (Governance|Packaging|Typing|Release))*$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-06-18 14:04:46 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-content-type
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "'Content-Type' must be 'text/x-rst'"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
2022-04-20 05:53:08 -04:00
|
|
|
entry: '^Content-Type:(?:(?! +text/x-rst$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-pep-references
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "`Requires`/`Replaces`/`Superseded-By` must be 'NNN' PEP IDs"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
2022-04-20 05:53:08 -04:00
|
|
|
entry: '^(Requires|Replaces|Superseded-By):(?:(?! *( (0|[1-9][0-9]{0,3})(,|$))+$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2021-03-22 15:29:08 -04:00
|
|
|
- id: validate-created
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "'Created' must be a 'DD-mmm-YYYY' date"
|
2021-03-22 15:29:08 -04:00
|
|
|
language: pygrep
|
2022-04-20 05:53:08 -04:00
|
|
|
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])$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-python-version
|
2022-04-20 05:53:08 -04:00
|
|
|
name: "'Python-Version' must be a 'X.Y[.Z]` version"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
2022-04-20 05:53:08 -04:00
|
|
|
entry: '^Python-Version:(?:(?! *( [1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?(,|$))+$))'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
|
|
|
- id: validate-post-history
|
|
|
|
name: "'Post-History' must be '`DD-mmm-YYYY <Thread URL>`__, ...'"
|
|
|
|
language: pygrep
|
2023-02-06 17:49:00 -05:00
|
|
|
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]))))'
|
2022-04-20 05:53:08 -04:00
|
|
|
args: [--multiline]
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2021-03-23 10:55:26 -04:00
|
|
|
- id: validate-resolution
|
2024-10-16 12:05:18 -04:00
|
|
|
name: "'Resolution' must be a direct thread/message URL or '`DD-mmm-YYYY <URL>`__'"
|
2021-03-23 10:55:26 -04:00
|
|
|
language: pygrep
|
2024-10-16 12:05:18 -04:00
|
|
|
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'
|
2021-03-23 10:55:26 -04:00
|
|
|
args: ['--multiline']
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2022-02-02 22:52:40 -05:00
|
|
|
- id: check-direct-pep-links
|
|
|
|
name: "Check that PEPs aren't linked directly"
|
|
|
|
language: pygrep
|
2022-03-24 16:02:08 -04:00
|
|
|
entry: '(dev/peps|peps\.python\.org)/pep-\d+'
|
2023-09-09 13:39:29 -04:00
|
|
|
files: '^peps/pep-\d+\.rst$'
|
|
|
|
exclude: '^peps/pep-(0009|0287|0676|0684|8001)\.rst$'
|
2022-04-20 05:53:08 -04:00
|
|
|
|
2022-02-02 22:52:40 -05:00
|
|
|
- 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+'
|
2023-09-09 13:39:29 -04:00
|
|
|
types: ['rst']
|