Upgrade lint infra & add a few more conservative built-in checks (#2286)

This commit is contained in:
CAM Gerlach 2022-01-31 20:49:58 -06:00 committed by GitHub
parent 47de64f1f5
commit e43f567e93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 87 additions and 29 deletions

8
.github/CODEOWNERS vendored
View File

@ -6,7 +6,7 @@
* @python/pep-editors * @python/pep-editors
# PEP infrastructure # PEP infrastructure
.github/workflows/ @AA-Turner .github/workflows/ @AA-Turner @CAM-Gerlach
Makefile @AA-Turner Makefile @AA-Turner
requirements.txt @AA-Turner requirements.txt @AA-Turner
.pre-commit-config.yml @CAM-Gerlach .pre-commit-config.yml @CAM-Gerlach
@ -38,6 +38,7 @@ pep-0009.txt @warsaw
pep-0010.txt @warsaw pep-0010.txt @warsaw
pep-0011.txt @brettcannon pep-0011.txt @brettcannon
pep-0012.rst @brettcannon @warsaw pep-0012.rst @brettcannon @warsaw
pep-0012/ @brettcannon
# pep-0013.rst is owned by the entire core team. # pep-0013.rst is owned by the entire core team.
# ... # ...
pep-0020.txt @tim-one pep-0020.txt @tim-one
@ -319,6 +320,7 @@ pep-0462.txt @ncoghlan
# pep-0463.txt # pep-0463.txt
pep-0464.txt @dstufft pep-0464.txt @dstufft
pep-0465.txt @njsmith pep-0465.txt @njsmith
pep-0465/ @njsmith
pep-0466.txt @ncoghlan pep-0466.txt @ncoghlan
pep-0467.txt @ncoghlan @ethanfurman pep-0467.txt @ncoghlan @ethanfurman
pep-0468.txt @ericsnowcurrently pep-0468.txt @ericsnowcurrently
@ -478,7 +480,7 @@ pep-0603-hamt_vs_dict.png @1st1
pep-0605.rst @zooba @ncoghlan pep-0605.rst @zooba @ncoghlan
pep-0605-example-release-calendar.png @zooba @ncoghlan pep-0605-example-release-calendar.png @zooba @ncoghlan
pep-0605-overlapping-support-matrix.png @zooba @ncoghlan pep-0605-overlapping-support-matrix.png @zooba @ncoghlan
/pep-0605/ @zooba @ncoghlan pep-0605/ @zooba @ncoghlan
pep-0606.rst @vstinner pep-0606.rst @vstinner
pep-0607.rst @ambv @zooba @ncoghlan pep-0607.rst @ambv @zooba @ncoghlan
pep-0608.rst @vstinner pep-0608.rst @vstinner
@ -536,7 +538,7 @@ pep-0659.rst @markshannon
pep-0660.rst @pfmoore pep-0660.rst @pfmoore
pep-0661.rst @taleinat pep-0661.rst @taleinat
pep-0662.rst @brettcannon pep-0662.rst @brettcannon
pep-0662/pep-0662-editables.json @brettcannon pep-0662/ @brettcannon
pep-0663.txt @ethanfurman pep-0663.txt @ethanfurman
pep-0664.rst @pablogsal pep-0664.rst @pablogsal
pep-0665.rst @brettcannon pep-0665.rst @brettcannon

View File

@ -1,13 +1,15 @@
name: Build name: Docutils Build
on: [push, pull_request, workflow_dispatch] on: [push, pull_request, workflow_dispatch]
jobs: jobs:
build: build:
name: Build with Docutils
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Check out repo
uses: actions/checkout@v2
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v2

View File

@ -1,9 +1,10 @@
name: Deploy to GitHub Pages name: Sphinx Build
on: [push, pull_request, workflow_dispatch] on: [push, pull_request, workflow_dispatch]
jobs: jobs:
deploy-to-pages: deploy-to-pages:
name: Build & deploy to GitHub Pages
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -15,13 +16,13 @@ jobs:
- name: 🐍 Set up Python 3 - name: 🐍 Set up Python 3
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3 python-version: '3.x'
cache: "pip" cache: "pip"
- name: 👷‍ Install dependencies - name: 👷‍ Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install -r requirements.txt python -m pip install --upgrade -r requirements.txt
- name: 🔧 Build PEPs - name: 🔧 Build PEPs
run: make pages -j$(nproc) run: make pages -j$(nproc)
@ -33,7 +34,7 @@ jobs:
- name: 🚀 Deploy to GitHub pages - name: 🚀 Deploy to GitHub pages
# This allows CI to build branches for testing # This allows CI to build branches for testing
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@4.1.1 uses: JamesIves/github-pages-deploy-action@v4.2.2
with: with:
branch: gh-pages # The branch to deploy to. branch: gh-pages # The branch to deploy to.
folder: build # Synchronise with build.py -> build_directory folder: build # Synchronise with build.py -> build_directory

View File

@ -4,8 +4,17 @@ on: [push, pull_request, workflow_dispatch]
jobs: jobs:
pre-commit: pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - name: Check out repo
- uses: actions/setup-python@v2 uses: actions/checkout@v2
- uses: pre-commit/action@v2.0.0
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Run pre-commit hooks
uses: pre-commit/action@v2.0.3

View File

@ -1,33 +1,77 @@
# 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]
repos: repos:
# General file checks and fixers
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0 rev: v4.1.0
hooks: hooks:
- id: mixed-line-ending - id: mixed-line-ending
name: Normalize mixed line endings name: "Normalize mixed line endings"
args: [--fix=lf] args: [--fix=lf]
- id: fix-byte-order-marker
name: "Remove Unicode BOM"
- 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"
- id: check-ast
name: "Check Python AST"
- id: check-json
name: "Check JSON"
- id: check-toml
name: "Check TOML"
- id: check-yaml
name: "Check YAML"
# RST checks
- repo: https://github.com/pre-commit/pygrep-hooks - repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.8.0 rev: v1.9.0
hooks: hooks:
- id: rst-backticks - id: rst-backticks
name: "Check RST: No single backticks"
- id: rst-inline-touching-normal - id: rst-inline-touching-normal
name: "Check RST: No backticks touching text"
files: '^pep-\d+\.txt|\.rst$' files: '^pep-\d+\.txt|\.rst$'
types: [text] types: [text]
- id: rst-directive-colons - id: rst-directive-colons
name: "Check RST: 2 colons after directives"
files: '^pep-\d+\.txt|\.rst$' files: '^pep-\d+\.txt|\.rst$'
types: [text] types: [text]
# Manual codespell check
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.1.0 rev: v2.1.0
hooks: hooks:
- id: codespell - id: codespell
name: Check for common misspellings in text files name: "Check for common misspellings in text files"
stages: [manual] stages: [manual]
# Local checks for PEP headers and more
- repo: local - repo: local
hooks: hooks:
- id: check-required-fields - id: check-required-fields
name: "Check all PEPs have required fields" name: "Check PEPs have all required fields"
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:))' 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']
@ -41,19 +85,19 @@ repos:
files: '^pep-\d+\.(rst|txt)$' files: '^pep-\d+\.(rst|txt)$'
types: [text] types: [text]
- id: validate-status - id: validate-status
name: "Validate PEP Status field" name: "Validate PEP 'Status' field"
language: pygrep language: pygrep
entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))' entry: '^Status:(?:(?! +(Draft|Withdrawn|Rejected|Accepted|Final|Active|Provisional|Deferred|Superseded|April Fool!)$))'
files: '^pep-\d+\.(rst|txt)$' files: '^pep-\d+\.(rst|txt)$'
types: [text] types: [text]
- id: validate-type - id: validate-type
name: "Validate PEP Type field" name: "Validate PEP 'Type' field"
language: pygrep language: pygrep
entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))' entry: '^Type:(?:(?! +(Standards Track|Informational|Process)$))'
files: '^pep-\d+\.(rst|txt)$' files: '^pep-\d+\.(rst|txt)$'
types: [text] types: [text]
- id: validate-content-type - id: validate-content-type
name: "Validate PEP Content-Type field" name: "Validate PEP 'Content-Type' field"
language: pygrep language: pygrep
entry: '^Content-Type:(?:(?! +text\/x-rst$))' entry: '^Content-Type:(?:(?! +text\/x-rst$))'
files: '^pep-\d+\.(rst|txt)$' files: '^pep-\d+\.(rst|txt)$'
@ -65,19 +109,19 @@ repos:
files: '^pep-\d+\.(rst|txt)$' files: '^pep-\d+\.(rst|txt)$'
types: [text] types: [text]
- id: validate-created - id: validate-created
name: "Validate created dates" name: "Validate PEP 'Created' field"
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])( \([^()]+\))?$))' 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)$' files: '^pep-\d+\.(rst|txt)$'
types: [text] types: [text]
- id: validate-python-version - id: validate-python-version
name: "Validate PEP Python-Version field" name: "Validate PEP 'Python-Version' field"
language: pygrep language: pygrep
entry: '^Python-Version:(?:(?! +( ?[1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?\??,?)+( \([^()]+\))?$))' entry: '^Python-Version:(?:(?! +( ?[1-9]\.([0-9][0-9]?|x)(\.[1-9][0-9]?)?\??,?)+( \([^()]+\))?$))'
files: '^pep-\d+\.(rst|txt)$' files: '^pep-\d+\.(rst|txt)$'
types: [text] types: [text]
- id: validate-resolution - id: validate-resolution
name: "Validate PEP Resolution field" name: "Validate PEP 'Resolution' field"
language: pygrep language: pygrep
entry: '(?<!\n\n)^Resolution: (?:(?!(https:\/\/\S*|:pep:`[a-zA-Z\d \-<>#]*?`)\n))' entry: '(?<!\n\n)^Resolution: (?:(?!(https:\/\/\S*|:pep:`[a-zA-Z\d \-<>#]*?`)\n))'
args: ['--multiline'] args: ['--multiline']

0
pep-0418/clockutils.py Normal file → Executable file
View File

2
scan-ops.py → pep-0465/scan-ops.py Normal file → Executable file
View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# http://legacy.python.org/dev/peps/pep-0465/ # https://www.python.org/dev/peps/pep-0465/
# https://gist.github.com/njsmith/9157645 # https://gist.github.com/njsmith/9157645
# usage: # usage:

View File

@ -308,7 +308,7 @@ References
.. [2] tp_call/PyObject_Call calling convention .. [2] tp_call/PyObject_Call calling convention
https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_call https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_call
.. [3] Using PY_VECTORCALL_ARGUMENTS_OFFSET in callee .. [3] Using PY_VECTORCALL_ARGUMENTS_OFFSET in callee
https://github.com/markshannon/cpython/blob/vectorcall-minimal/Objects/classobject.c#L53 https://github.com/markshannon/cpython/blob/815cc1a30d85cdf2e3d77d21224db7055a1f07cb/Objects/classobject.c#L53
.. [4] Argument Clinic .. [4] Argument Clinic
https://docs.python.org/3/howto/clinic.html https://docs.python.org/3/howto/clinic.html

View File

@ -97,8 +97,8 @@ but also on the value of some class attributes, like the ``BinOp``
example above. The Visitor pattern is insufficiently flexible for example above. The Visitor pattern is insufficiently flexible for
this: it can only select based on the class. this: it can only select based on the class.
For a complete example, see See a `complete example
https://github.com/gvanrossum/patma/blob/master/examples/expr.py#L231 <https://github.com/gvanrossum/patma/blob/be5969442d0584005492134c3b24eea408709db2/examples/expr.py#L231>`_.
Like the Visitor pattern, pattern matching allows for a strict separation Like the Visitor pattern, pattern matching allows for a strict separation
of concerns: specific actions or data processing is independent of the of concerns: specific actions or data processing is independent of the

View File

@ -1356,7 +1356,7 @@ they don't define ``__match_args__`` (the optimised fast path for the builtin
and standard library types named in :pep:`634` is retained). and standard library types named in :pep:`634` is retained).
Adapting the class matching example Adapting the class matching example
`linked from PEP 635 <https://github.com/gvanrossum/patma/blob/master/examples/expr.py#L231>`_ `linked from PEP 635 <https://github.com/gvanrossum/patma/blob/be5969442d0584005492134c3b24eea408709db2/examples/expr.py#L231>`_
shows that for purely positional class matching, the main impact comes from the shows that for purely positional class matching, the main impact comes from the
changes to value constraints and name binding, not from the class matching changes to value constraints and name binding, not from the class matching
changes:: changes::

View File

@ -819,7 +819,7 @@ and render HTML as-is is to use functions like ``mark_safe`` in
`Django `Django
<https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.safestring.mark_safe>`_ <https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.safestring.mark_safe>`_
or ``do_mark_safe`` in `Jinja2 or ``do_mark_safe`` in `Jinja2
<https://github.com/pallets/jinja/blob/main/src/jinja2/filters.py#L1264>`_, <https://github.com/pallets/jinja/blob/077b7918a7642ff6742fe48a32e54d7875140894/src/jinja2/filters.py#L1264>`_,
which cause XSS vulnerabilities: which cause XSS vulnerabilities:
:: ::