Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint: Validate PEP fields against PEP 12 #1890

Merged
merged 8 commits into from
Mar 23, 2021
54 changes: 49 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,60 @@ repos:

- repo: local
hooks:
- id: check-created-exists
name: "Check all PEPs have created date"
- id: check-required-fields
name: "Check all PEPs have required fields"
language: pygrep
entry: '^Created:'
args: ['--negate']
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 created dates"
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])( \(|$)))'
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*\n))'
args: ['--multiline']
files: '^pep-\d+\.(rst|txt)$'
types: [text]
1 change: 0 additions & 1 deletion pep-0316.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Status: Deferred
Type: Standards Track
Content-Type: text/x-rst
Created: 02-May-2003
Python-Version:
Post-History:


Expand Down
2 changes: 1 addition & 1 deletion pep-0328.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Status: Final
Type: Standards Track
Content-Type: text/x-rst
Created: 21-Dec-2003
Python-Version: 2.4, 2,5, 2.6
Python-Version: 2.4, 2.5, 2.6
Post-History: 8-Mar-2004


Expand Down
2 changes: 1 addition & 1 deletion pep-0361.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Status: Final
Type: Informational
Content-Type: text/x-rst
Created: 29-Jun-2006
Python-Version: 2.6 and 3.0
Python-Version: 2.6, 3.0
Post-History: 17-Mar-2008


Expand Down
2 changes: 1 addition & 1 deletion pep-0371.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Status: Final
Type: Standards Track
Content-Type: text/x-rst
Created: 06-May-2008
Python-Version: 2.6 / 3.0
Python-Version: 2.6, 3.0
Post-History:


Expand Down
2 changes: 1 addition & 1 deletion pep-0378.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Status: Final
Type: Standards Track
Content-Type: text/x-rst
Created: 12-Mar-2009
Python-Version: 2.7 and 3.1
Python-Version: 2.7, 3.1
Post-History: 12-Mar-2009


Expand Down
1 change: 0 additions & 1 deletion pep-0381.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Status: Withdrawn
Type: Standards Track
Content-Type: text/x-rst
Created: 21-Mar-2009
Python-Version: N.A.
Post-History:


Expand Down
2 changes: 1 addition & 1 deletion pep-0389.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Status: Final
Type: Standards Track
Content-Type: text/x-rst
Created: 25-Sep-2009
Python-Version: 2.7 and 3.2
Python-Version: 2.7, 3.2
Post-History: 27-Sep-2009, 24-Oct-2009


Expand Down
2 changes: 1 addition & 1 deletion pep-0390.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Status: Rejected
Type: Standards Track
Content-Type: text/x-rst
Created: 10-Oct-2009
Python-Version: 2.7 and 3.2
Python-Version: 2.7, 3.2
Post-History:
Resolution: https://mail.python.org/pipermail/distutils-sig/2013-April/020597.html

Expand Down
1 change: 0 additions & 1 deletion pep-0403.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Content-Type: text/x-rst
Created: 13-Oct-2011
Python-Version: 3.4
Post-History: 2011-10-13
Resolution: TBD


Abstract
Expand Down
1 change: 0 additions & 1 deletion pep-0407.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Type: Process
Content-Type: text/x-rst
Created: 12-Jan-2012
Post-History: 17-Jan-2012
Resolution: TBD


Abstract
Expand Down
2 changes: 1 addition & 1 deletion pep-0412.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Status: Final
Type: Standards Track
Content-Type: text/x-rst
Created: 08-Feb-2012
Python-Version: 3.3 or 3.4
Python-Version: 3.3
Post-History: 08-Feb-2012


Expand Down
1 change: 0 additions & 1 deletion pep-0413.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Type: Process
Content-Type: text/x-rst
Created: 24-Feb-2012
Post-History: 2012-02-24, 2012-02-25
Resolution: TBD


PEP Withdrawal
Expand Down
2 changes: 1 addition & 1 deletion pep-0482.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Type: Informational
Content-Type: text/x-rst
Created: 08-Jan-2015
Post-History:
Resolution:


Abstract
========
Expand Down
2 changes: 1 addition & 1 deletion pep-0483.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Type: Informational
Content-Type: text/x-rst
Created: 19-Dec-2014
Post-History:
Resolution:


Abstract
========
Expand Down
2 changes: 1 addition & 1 deletion pep-0541.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Type: Process
Content-Type: text/x-rst
Created: 12-Jan-2017
Post-History:
Resolution: https://mail.python.org/pipermail/distutils-sig/2018-March/032089.html
Resolution: https://mail.python.org/pipermail/distutils-sig/2018-March/032089.html


Abstract
Expand Down
2 changes: 1 addition & 1 deletion pep-0617.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PEP: 0617
PEP: 617
Title: New PEG parser for CPython
Version: $Revision$
Last-Modified: $Date$
Expand Down
1 change: 0 additions & 1 deletion pep-0622.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Created: 23-Jun-2020
Python-Version: 3.10
Post-History: 23-Jun-2020, 8-Jul-2020
Superseded-By: 634
Resolution:


Abstract
Expand Down
2 changes: 1 addition & 1 deletion pep-0628.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Content-Type: text/x-rst
Created: 28-Jun-2011
Python-Version: 3.6
Post-History: 28-Jun-2011
Resolution: http://bugs.python.org/issue12345
Resolution: https://bugs.python.org/issue12345


Abstract
Expand Down
2 changes: 1 addition & 1 deletion pep-0648.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PEP: 0648
PEP: 648
Title: Extensible customizations of the interpreter at startup
Author: Mario Corchero <mariocj89@gmail.com>
Sponsor: Pablo Galindo
Expand Down
2 changes: 1 addition & 1 deletion pep-3118.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Status: Final
Type: Standards Track
Content-Type: text/x-rst
Created: 28-Aug-2006
Python-Version: 3000
Python-Version: 3.0
Post-History:

Abstract
Expand Down
2 changes: 1 addition & 1 deletion pep-3128.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Status: Rejected
Type: Standards Track
Content-Type: text/x-rst
Created: 30-Apr-2007
Python-Version: 2.6 and/or 3.0
Python-Version: 2.6, 3.0
Post-History: 30-Apr-2007


Expand Down
1 change: 0 additions & 1 deletion pep-3150.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Content-Type: text/x-rst
Created: 09-Jul-2010
Python-Version: 3.4
Post-History: 2010-07-14, 2011-04-21, 2011-06-13
Resolution: TBD


Abstract
Expand Down