Skip to content

Commit e43f567

Browse files
authored
Upgrade lint infra & add a few more conservative built-in checks (#2286)
1 parent 47de64f commit e43f567

File tree

11 files changed

+87
-29
lines changed

11 files changed

+87
-29
lines changed

.github/CODEOWNERS

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @python/pep-editors
77

88
# PEP infrastructure
9-
.github/workflows/ @AA-Turner
9+
.github/workflows/ @AA-Turner @CAM-Gerlach
1010
Makefile @AA-Turner
1111
requirements.txt @AA-Turner
1212
.pre-commit-config.yml @CAM-Gerlach
@@ -38,6 +38,7 @@ pep-0009.txt @warsaw
3838
pep-0010.txt @warsaw
3939
pep-0011.txt @brettcannon
4040
pep-0012.rst @brettcannon @warsaw
41+
pep-0012/ @brettcannon
4142
# pep-0013.rst is owned by the entire core team.
4243
# ...
4344
pep-0020.txt @tim-one
@@ -319,6 +320,7 @@ pep-0462.txt @ncoghlan
319320
# pep-0463.txt
320321
pep-0464.txt @dstufft
321322
pep-0465.txt @njsmith
323+
pep-0465/ @njsmith
322324
pep-0466.txt @ncoghlan
323325
pep-0467.txt @ncoghlan @ethanfurman
324326
pep-0468.txt @ericsnowcurrently
@@ -478,7 +480,7 @@ pep-0603-hamt_vs_dict.png @1st1
478480
pep-0605.rst @zooba @ncoghlan
479481
pep-0605-example-release-calendar.png @zooba @ncoghlan
480482
pep-0605-overlapping-support-matrix.png @zooba @ncoghlan
481-
/pep-0605/ @zooba @ncoghlan
483+
pep-0605/ @zooba @ncoghlan
482484
pep-0606.rst @vstinner
483485
pep-0607.rst @ambv @zooba @ncoghlan
484486
pep-0608.rst @vstinner
@@ -536,7 +538,7 @@ pep-0659.rst @markshannon
536538
pep-0660.rst @pfmoore
537539
pep-0661.rst @taleinat
538540
pep-0662.rst @brettcannon
539-
pep-0662/pep-0662-editables.json @brettcannon
541+
pep-0662/ @brettcannon
540542
pep-0663.txt @ethanfurman
541543
pep-0664.rst @pablogsal
542544
pep-0665.rst @brettcannon

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
name: Build
1+
name: Docutils Build
22

33
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
build:
7+
name: Build with Docutils
78
runs-on: ubuntu-latest
89

910
steps:
10-
- uses: actions/checkout@v2
11+
- name: Check out repo
12+
uses: actions/checkout@v2
1113

1214
- name: Set up Python
1315
uses: actions/setup-python@v2

.github/workflows/deploy-gh-pages.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
name: Deploy to GitHub Pages
1+
name: Sphinx Build
22

33
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
deploy-to-pages:
7+
name: Build & deploy to GitHub Pages
78
runs-on: ubuntu-latest
89

910
steps:
@@ -15,13 +16,13 @@ jobs:
1516
- name: 🐍 Set up Python 3
1617
uses: actions/setup-python@v2
1718
with:
18-
python-version: 3
19+
python-version: '3.x'
1920
cache: "pip"
2021

2122
- name: 👷‍ Install dependencies
2223
run: |
2324
python -m pip install --upgrade pip
24-
python -m pip install -r requirements.txt
25+
python -m pip install --upgrade -r requirements.txt
2526
2627
- name: 🔧 Build PEPs
2728
run: make pages -j$(nproc)
@@ -33,7 +34,7 @@ jobs:
3334
- name: 🚀 Deploy to GitHub pages
3435
# This allows CI to build branches for testing
3536
if: github.ref == 'refs/heads/main'
36-
uses: JamesIves/github-pages-deploy-action@4.1.1
37+
uses: JamesIves/github-pages-deploy-action@v4.2.2
3738
with:
3839
branch: gh-pages # The branch to deploy to.
3940
folder: build # Synchronise with build.py -> build_directory

.github/workflows/lint.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
pre-commit:
7+
name: Run pre-commit
78
runs-on: ubuntu-latest
9+
810
steps:
9-
- uses: actions/checkout@v2
10-
- uses: actions/setup-python@v2
11-
- uses: pre-commit/action@v2.0.0
11+
- name: Check out repo
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Python 3
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: '3.x'
18+
19+
- name: Run pre-commit hooks
20+
uses: pre-commit/action@v2.0.3

.pre-commit-config.yaml

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,77 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
4+
minimum_pre_commit_version: '2.8.2'
5+
6+
default_language_version:
7+
python: python3
8+
9+
default_stages: [commit]
10+
11+
112
repos:
13+
# General file checks and fixers
214
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.4.0
15+
rev: v4.1.0
416
hooks:
517
- id: mixed-line-ending
6-
name: Normalize mixed line endings
18+
name: "Normalize mixed line endings"
719
args: [--fix=lf]
20+
- id: fix-byte-order-marker
21+
name: "Remove Unicode BOM"
22+
- id: file-contents-sorter
23+
name: "Sort codespell ignore list"
24+
files: '.codespell/ignore-words.txt'
25+
26+
- id: check-case-conflict
27+
name: "Check for case conflicts"
28+
- id: check-merge-conflict
29+
name: "Check for merge conflict markers"
30+
- id: check-executables-have-shebangs
31+
name: "Check that executables have shebangs"
32+
- id: check-shebang-scripts-are-executable
33+
name: "Check that shebangs are executable"
34+
35+
- id: check-vcs-permalinks
36+
name: "Check that VCS links are permalinks"
37+
38+
- id: check-ast
39+
name: "Check Python AST"
40+
- id: check-json
41+
name: "Check JSON"
42+
- id: check-toml
43+
name: "Check TOML"
44+
- id: check-yaml
45+
name: "Check YAML"
846

47+
# RST checks
948
- repo: https://github.com/pre-commit/pygrep-hooks
10-
rev: v1.8.0
49+
rev: v1.9.0
1150
hooks:
1251
- id: rst-backticks
52+
name: "Check RST: No single backticks"
1353
- id: rst-inline-touching-normal
54+
name: "Check RST: No backticks touching text"
1455
files: '^pep-\d+\.txt|\.rst$'
1556
types: [text]
1657
- id: rst-directive-colons
58+
name: "Check RST: 2 colons after directives"
1759
files: '^pep-\d+\.txt|\.rst$'
1860
types: [text]
1961

62+
# Manual codespell check
2063
- repo: https://github.com/codespell-project/codespell
2164
rev: v2.1.0
2265
hooks:
2366
- id: codespell
24-
name: Check for common misspellings in text files
67+
name: "Check for common misspellings in text files"
2568
stages: [manual]
2669

70+
# Local checks for PEP headers and more
2771
- repo: local
2872
hooks:
2973
- id: check-required-fields
30-
name: "Check all PEPs have required fields"
74+
name: "Check PEPs have all required fields"
3175
language: pygrep
3276
entry: '(?-m:^PEP:(?=[\s\S]*\nTitle:)(?=[\s\S]*\nAuthor:)(?=[\s\S]*\nStatus:)(?=[\s\S]*\nType:)(?=[\s\S]*\nContent-Type:)(?=[\s\S]*\nCreated:))'
3377
args: ['--negate', '--multiline']
@@ -41,19 +85,19 @@ repos:
4185
files: '^pep-\d+\.(rst|txt)$'
4286
types: [text]
4387
- id: validate-status
44-
name: "Validate PEP Status field"
88+
name: "Validate PEP 'Status' field"
4589
language: pygrep
4690
entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))'
4791
files: '^pep-\d+\.(rst|txt)$'
4892
types: [text]
4993
- id: validate-type
50-
name: "Validate PEP Type field"
94+
name: "Validate PEP 'Type' field"
5195
language: pygrep
5296
entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))'
5397
files: '^pep-\d+\.(rst|txt)$'
5498
types: [text]
5599
- id: validate-content-type
56-
name: "Validate PEP Content-Type field"
100+
name: "Validate PEP 'Content-Type' field"
57101
language: pygrep
58102
entry: '^Content-Type:(?:(?! +text\/x-rst$))'
59103
files: '^pep-\d+\.(rst|txt)$'
@@ -65,19 +109,19 @@ repos:
65109
files: '^pep-\d+\.(rst|txt)$'
66110
types: [text]
67111
- id: validate-created
68-
name: "Validate created dates"
112+
name: "Validate PEP 'Created' field"
69113
language: pygrep
70114
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])( \([^()]+\))?$))'
71115
files: '^pep-\d+\.(rst|txt)$'
72116
types: [text]
73117
- id: validate-python-version
74-
name: "Validate PEP Python-Version field"
118+
name: "Validate PEP 'Python-Version' field"
75119
language: pygrep
76120
entry: '^Python-Version:(?:(?! +( ?[1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?\??,?)+( \([^()]+\))?$))'
77121
files: '^pep-\d+\.(rst|txt)$'
78122
types: [text]
79123
- id: validate-resolution
80-
name: "Validate PEP Resolution field"
124+
name: "Validate PEP 'Resolution' field"
81125
language: pygrep
82126
entry: '(?<!\n\n)^Resolution: (?:(?!(https:\/\/\S*|:pep:`[a-zA-Z\d \-<>#]*?`)\n))'
83127
args: ['--multiline']

pep-0418/clockutils.py

100644100755
File mode changed.

scan-ops.py renamed to pep-0465/scan-ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# http://legacy.python.org/dev/peps/pep-0465/
2+
# https://www.python.org/dev/peps/pep-0465/
33
# https://gist.github.com/njsmith/9157645
44

55
# usage:

pep-0590.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ References
308308
.. [2] tp_call/PyObject_Call calling convention
309309
https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_call
310310
.. [3] Using PY_VECTORCALL_ARGUMENTS_OFFSET in callee
311-
https://github.com/markshannon/cpython/blob/vectorcall-minimal/Objects/classobject.c#L53
311+
https://github.com/markshannon/cpython/blob/815cc1a30d85cdf2e3d77d21224db7055a1f07cb/Objects/classobject.c#L53
312312
.. [4] Argument Clinic
313313
https://docs.python.org/3/howto/clinic.html
314314

pep-0635.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ but also on the value of some class attributes, like the ``BinOp``
9797
example above. The Visitor pattern is insufficiently flexible for
9898
this: it can only select based on the class.
9999

100-
For a complete example, see
101-
https://github.com/gvanrossum/patma/blob/master/examples/expr.py#L231
100+
See a `complete example
101+
<https://github.com/gvanrossum/patma/blob/be5969442d0584005492134c3b24eea408709db2/examples/expr.py#L231>`_.
102102

103103
Like the Visitor pattern, pattern matching allows for a strict separation
104104
of concerns: specific actions or data processing is independent of the

pep-0642.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ they don't define ``__match_args__`` (the optimised fast path for the builtin
13561356
and standard library types named in :pep:`634` is retained).
13571357

13581358
Adapting the class matching example
1359-
`linked from PEP 635 <https://github.com/gvanrossum/patma/blob/master/examples/expr.py#L231>`_
1359+
`linked from PEP 635 <https://github.com/gvanrossum/patma/blob/be5969442d0584005492134c3b24eea408709db2/examples/expr.py#L231>`_
13601360
shows that for purely positional class matching, the main impact comes from the
13611361
changes to value constraints and name binding, not from the class matching
13621362
changes::

pep-0675.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ and render HTML as-is is to use functions like ``mark_safe`` in
819819
`Django
820820
<https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.safestring.mark_safe>`_
821821
or ``do_mark_safe`` in `Jinja2
822-
<https://github.com/pallets/jinja/blob/main/src/jinja2/filters.py#L1264>`_,
822+
<https://github.com/pallets/jinja/blob/077b7918a7642ff6742fe48a32e54d7875140894/src/jinja2/filters.py#L1264>`_,
823823
which cause XSS vulnerabilities:
824824

825825
::

0 commit comments

Comments
 (0)