From 2a5dbf297af46a6c6345ba61775f39b520cb730a Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 27 Jan 2022 14:05:28 -0600 Subject: [PATCH 1/5] Add and clarify documentation/UI text for pre-commit and actions --- .github/workflows/build.yml | 6 ++++-- .github/workflows/deploy-gh-pages.yml | 3 ++- .github/workflows/lint.yml | 13 ++++++++++--- .pre-commit-config.yaml | 28 ++++++++++++++++++--------- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 535dbd1302f..622f5b2bfd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,15 @@ -name: Build +name: Docutils Build on: [push, pull_request, workflow_dispatch] jobs: build: + name: Build with Docutils runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Check out repo + uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml index 8f61e4b14a7..9df38d77c04 100644 --- a/.github/workflows/deploy-gh-pages.yml +++ b/.github/workflows/deploy-gh-pages.yml @@ -1,9 +1,10 @@ -name: Deploy to GitHub Pages +name: Sphinx Build on: [push, pull_request, workflow_dispatch] jobs: deploy-to-pages: + name: Build & deploy to GitHub Pages runs-on: ubuntu-latest steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4f3c2c941cf..014fc52da8c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,8 +4,15 @@ on: [push, pull_request, workflow_dispatch] jobs: pre-commit: + name: Run pre-commit runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.0 + - name: Check out repo + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + + - name: Run pre-commit hooks + uses: pre-commit/action@v2.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb9238a528a..f17671fdbbd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,43 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + repos: + # General file checks - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: - id: mixed-line-ending - name: Normalize mixed line endings + name: "Normalize mixed line endings" args: [--fix=lf] + # RST checks - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.8.0 hooks: - id: rst-backticks + name: "Check RST single backticks" - id: rst-inline-touching-normal + name: "Check RST inline touching normal" files: '^pep-\d+\.txt|\.rst$' types: [text] - id: rst-directive-colons + name: "Check RST colons after directives" files: '^pep-\d+\.txt|\.rst$' types: [text] + # Manual codespell check - repo: https://github.com/codespell-project/codespell rev: v2.1.0 hooks: - id: codespell - name: Check for common misspellings in text files + name: "Check for common misspellings in text files" stages: [manual] + # Local checks for PEP headers and more - repo: local hooks: - id: check-required-fields - name: "Check all PEPs have required fields" + name: "Check PEPs have all required fields" 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'] @@ -41,19 +51,19 @@ repos: files: '^pep-\d+\.(rst|txt)$' types: [text] - id: validate-status - name: "Validate PEP Status field" + 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" + 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" + name: "Validate PEP 'Content-Type' field" language: pygrep entry: '^Content-Type:(?:(?! +text\/x-rst$))' files: '^pep-\d+\.(rst|txt)$' @@ -65,19 +75,19 @@ repos: files: '^pep-\d+\.(rst|txt)$' types: [text] - id: validate-created - name: "Validate created dates" + name: "Validate PEP 'Created' field" 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: '^pep-\d+\.(rst|txt)$' types: [text] - id: validate-python-version - name: "Validate PEP Python-Version field" + 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" + name: "Validate PEP 'Resolution' field" language: pygrep entry: '(?#]*?`)\n))' args: ['--multiline'] From cce31b87d55753e5729b55004600009b883446ce Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 27 Jan 2022 14:45:17 -0600 Subject: [PATCH 2/5] Upgrade pre-commit hook and GH action versions and boilerplate --- .github/CODEOWNERS | 2 +- .github/workflows/deploy-gh-pages.yml | 6 +++--- .github/workflows/lint.yml | 6 ++++-- .pre-commit-config.yaml | 12 ++++++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9f05d6c3302..1ac3f9deb50 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,7 +6,7 @@ * @python/pep-editors # PEP infrastructure -.github/workflows/ @AA-Turner +.github/workflows/ @AA-Turner @CAM-Gerlach Makefile @AA-Turner requirements.txt @AA-Turner .pre-commit-config.yml @CAM-Gerlach diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml index 9df38d77c04..de95eb3445c 100644 --- a/.github/workflows/deploy-gh-pages.yml +++ b/.github/workflows/deploy-gh-pages.yml @@ -16,13 +16,13 @@ jobs: - name: 🐍 Set up Python 3 uses: actions/setup-python@v2 with: - python-version: 3 + python-version: '3.x' cache: "pip" - name: 👷‍ Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -r requirements.txt + python -m pip install --upgrade -r requirements.txt - name: 🔧 Build PEPs run: make pages -j$(nproc) @@ -34,7 +34,7 @@ jobs: - name: 🚀 Deploy to GitHub pages # This allows CI to build branches for testing 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: branch: gh-pages # The branch to deploy to. folder: build # Synchronise with build.py -> build_directory diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 014fc52da8c..ee5cd980ec4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,8 +11,10 @@ jobs: - name: Check out repo uses: actions/checkout@v2 - - name: Set up Python + - 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.0 + uses: pre-commit/action@v2.0.3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f17671fdbbd..1a28e93df18 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,18 @@ # 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: # General file checks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.1.0 hooks: - id: mixed-line-ending name: "Normalize mixed line endings" @@ -12,7 +20,7 @@ repos: # RST checks - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.8.0 + rev: v1.9.0 hooks: - id: rst-backticks name: "Check RST single backticks" From 28d2393cc3d9d64c0973313fef7b042944e77f44 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 27 Jan 2022 16:16:58 -0600 Subject: [PATCH 3/5] PEP 465: Move ambigiously-named file out of root; update codeowners --- .github/CODEOWNERS | 6 ++++-- scan-ops.py => pep-0465/scan-ops.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) rename scan-ops.py => pep-0465/scan-ops.py (98%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1ac3f9deb50..450734e108f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -38,6 +38,7 @@ pep-0009.txt @warsaw pep-0010.txt @warsaw pep-0011.txt @brettcannon pep-0012.rst @brettcannon @warsaw +pep-0012/ @brettcannon # pep-0013.rst is owned by the entire core team. # ... pep-0020.txt @tim-one @@ -319,6 +320,7 @@ pep-0462.txt @ncoghlan # pep-0463.txt pep-0464.txt @dstufft pep-0465.txt @njsmith +pep-0465/ @njsmith pep-0466.txt @ncoghlan pep-0467.txt @ncoghlan @ethanfurman pep-0468.txt @ericsnowcurrently @@ -478,7 +480,7 @@ pep-0603-hamt_vs_dict.png @1st1 pep-0605.rst @zooba @ncoghlan pep-0605-example-release-calendar.png @zooba @ncoghlan pep-0605-overlapping-support-matrix.png @zooba @ncoghlan -/pep-0605/ @zooba @ncoghlan +pep-0605/ @zooba @ncoghlan pep-0606.rst @vstinner pep-0607.rst @ambv @zooba @ncoghlan pep-0608.rst @vstinner @@ -536,7 +538,7 @@ pep-0659.rst @markshannon pep-0660.rst @pfmoore pep-0661.rst @taleinat pep-0662.rst @brettcannon -pep-0662/pep-0662-editables.json @brettcannon +pep-0662/ @brettcannon pep-0663.txt @ethanfurman pep-0664.rst @pablogsal pep-0665.rst @brettcannon diff --git a/scan-ops.py b/pep-0465/scan-ops.py similarity index 98% rename from scan-ops.py rename to pep-0465/scan-ops.py index 79603b598b3..ac99037cb61 100644 --- a/scan-ops.py +++ b/pep-0465/scan-ops.py @@ -1,5 +1,5 @@ #!/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 # usage: From b884f7771d3a70f04358c3aabcc3cddb23a7bebe Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 27 Jan 2022 20:15:57 -0600 Subject: [PATCH 4/5] Add a few additional built-in pre-commit checks and fix issues detected --- .pre-commit-config.yaml | 28 +++++++++++++++++++++++++++- pep-0418/clockutils.py | 0 pep-0465/scan-ops.py | 0 pep-0590.rst | 2 +- pep-0635.rst | 4 ++-- pep-0642.rst | 2 +- pep-0675.rst | 2 +- 7 files changed, 32 insertions(+), 6 deletions(-) mode change 100644 => 100755 pep-0418/clockutils.py mode change 100644 => 100755 pep-0465/scan-ops.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a28e93df18..22aba18915f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,13 +10,39 @@ default_stages: [commit] repos: - # General file checks + # General file checks and fixers - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: - id: mixed-line-ending name: "Normalize mixed line endings" 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 diff --git a/pep-0418/clockutils.py b/pep-0418/clockutils.py old mode 100644 new mode 100755 diff --git a/pep-0465/scan-ops.py b/pep-0465/scan-ops.py old mode 100644 new mode 100755 diff --git a/pep-0590.rst b/pep-0590.rst index 41298d5534e..a3fa010fa06 100644 --- a/pep-0590.rst +++ b/pep-0590.rst @@ -308,7 +308,7 @@ References .. [2] tp_call/PyObject_Call calling convention https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_call .. [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 https://docs.python.org/3/howto/clinic.html diff --git a/pep-0635.rst b/pep-0635.rst index 97a547aa3cf..d3ff5a55fda 100644 --- a/pep-0635.rst +++ b/pep-0635.rst @@ -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 this: it can only select based on the class. -For a complete example, see -https://github.com/gvanrossum/patma/blob/master/examples/expr.py#L231 +See a `complete example +`_. Like the Visitor pattern, pattern matching allows for a strict separation of concerns: specific actions or data processing is independent of the diff --git a/pep-0642.rst b/pep-0642.rst index b06af6dc99f..6932bedb29b 100644 --- a/pep-0642.rst +++ b/pep-0642.rst @@ -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). Adapting the class matching example -`linked from PEP 635 `_ +`linked from PEP 635 `_ 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:: diff --git a/pep-0675.rst b/pep-0675.rst index 640452a3cde..a1b0464eb90 100644 --- a/pep-0675.rst +++ b/pep-0675.rst @@ -819,7 +819,7 @@ and render HTML as-is is to use functions like ``mark_safe`` in `Django `_ or ``do_mark_safe`` in `Jinja2 -`_, +`_, which cause XSS vulnerabilities: :: From d67d3b8321450fd95121fcd78d575d1293478a0b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 31 Jan 2022 18:46:34 -0800 Subject: [PATCH 5/5] Update .pre-commit-config.yaml Co-authored-by: CAM Gerlach --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22aba18915f..a98015fbdec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,13 +49,13 @@ repos: rev: v1.9.0 hooks: - id: rst-backticks - name: "Check RST single backticks" + name: "Check RST: No single backticks" - id: rst-inline-touching-normal - name: "Check RST inline touching normal" + name: "Check RST: No backticks touching text" files: '^pep-\d+\.txt|\.rst$' types: [text] - id: rst-directive-colons - name: "Check RST colons after directives" + name: "Check RST: 2 colons after directives" files: '^pep-\d+\.txt|\.rst$' types: [text]