From de70b1db1d74a7cd9824993a3ad989daa5dd8c04 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 11 Apr 2022 07:13:38 +0200 Subject: [PATCH 1/4] Bootstrap pre-commit.ci This adds no new code linters or formatters, but ensures that flake8 (and some minor others) are run using pre-commit.ci on each PR. That's very fast and fixes problems in-PR, not requiring review turnarounds. Additionally we get more stable linters via version pinning for free. The updates are capped to once per month to prevent unnecessary churn. Since flake8 now runs over the whole code base, I've added a few noqas where it made sense. --- .github/workflows/ci.yml | 4 ---- .gitignore | 2 +- .pre-commit-config.yaml | 19 +++++++++++++++++++ admin/check_tag_version_match.py | 2 +- bin/towncrier | 1 + docs/Makefile | 2 +- docs/conf.py | 3 --- docs/configuration.rst | 2 +- setup.py | 2 +- src/towncrier/newsfragments/330.misc | 1 - src/towncrier/newsfragments/367.doc.rst | 2 +- src/towncrier/newsfragments/369.feature.rst | 2 +- src/towncrier/test/test_build.py | 2 +- tox.ini | 9 +-------- 14 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cabc95d..0ce889d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,12 +130,8 @@ jobs: tox: py39 action: 3.9 task: - - name: Flake8 - tox: flake8 - name: Check Newsfragment tox: check-newsfragment - - name: Run pre-commit hooks - tox: pre-commit steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 0bf4874c..75e82d46 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ apidocs/ .coverage.* .vscode .idea -.python-version \ No newline at end of file +.python-version diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e7ee28de..3e482e48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,26 @@ --- +ci: + autoupdate_schedule: monthly + repos: - repo: https://github.com/asottile/pyupgrade rev: v2.31.1 hooks: - id: pyupgrade args: [--py37-plus] + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + language_version: python3.10 + exclude: docs/code_examples + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: debug-statements + - id: check-toml + - id: check-yaml diff --git a/admin/check_tag_version_match.py b/admin/check_tag_version_match.py index 1fbd344f..9fabd4da 100644 --- a/admin/check_tag_version_match.py +++ b/admin/check_tag_version_match.py @@ -24,7 +24,7 @@ print(f"Not a twisted release tag name '{run_version}.") sys.exit(1) -run_version = run_version[len(TAG_PREFIX) :] +run_version = run_version[len(TAG_PREFIX) :] # noqa: E203 if run_version != branch_version: print(f"Branch is at '{branch_version}' while tag is '{run_version}'") diff --git a/bin/towncrier b/bin/towncrier index 9c986937..f76f7186 100755 --- a/bin/towncrier +++ b/bin/towncrier @@ -1,4 +1,5 @@ #! /usr/bin/env python3 +# flake8: noqa import sys import os.path diff --git a/docs/Makefile b/docs/Makefile index 1107e53c..e25b0b5c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -17,4 +17,4 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py index c6300a0c..855dbd0f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -165,6 +165,3 @@ author, 'Towncrier', 'One line description of project.', 'Miscellaneous'), ] - - - diff --git a/docs/configuration.rst b/docs/configuration.rst index 144598c3..cc904ce0 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -93,4 +93,4 @@ For example: [[tool.towncrier.type]] directory = "chore" name = "Other Tasks" - showcontent = false \ No newline at end of file + showcontent = false diff --git a/setup.py b/setup.py index 3241e35a..d648b45a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ # If incremental is not present then setuptools just silently uses v0.0.0 so # let's import it and fail instead. -import incremental +import incremental # noqa setup( diff --git a/src/towncrier/newsfragments/330.misc b/src/towncrier/newsfragments/330.misc index 8b137891..e69de29b 100644 --- a/src/towncrier/newsfragments/330.misc +++ b/src/towncrier/newsfragments/330.misc @@ -1 +0,0 @@ - diff --git a/src/towncrier/newsfragments/367.doc.rst b/src/towncrier/newsfragments/367.doc.rst index a53a4669..613c83b4 100644 --- a/src/towncrier/newsfragments/367.doc.rst +++ b/src/towncrier/newsfragments/367.doc.rst @@ -1 +1 @@ -Move docs too master branch and document custom fragment types. \ No newline at end of file +Move docs too master branch and document custom fragment types. diff --git a/src/towncrier/newsfragments/369.feature.rst b/src/towncrier/newsfragments/369.feature.rst index 2fa0986c..6f1816e0 100644 --- a/src/towncrier/newsfragments/369.feature.rst +++ b/src/towncrier/newsfragments/369.feature.rst @@ -1,2 +1,2 @@ Added support to tables in toml settings, which provides a more intuitive -way to configure custom types. \ No newline at end of file +way to configure custom types. diff --git a/src/towncrier/test/test_build.py b/src/towncrier/test/test_build.py index 0b45a924..5562a2f7 100644 --- a/src/towncrier/test/test_build.py +++ b/src/towncrier/test/test_build.py @@ -670,7 +670,7 @@ def test_bullet_points_false(self): ) self.assertEqual(0, result.exit_code, result.output) - with open("NEWS.rst", "r") as f: + with open("NEWS.rst") as f: output = f.read() self.assertEqual( diff --git a/tox.ini b/tox.ini index 4ad01f85..033739d4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,8 @@ [tox] -envlist = cov-erase, flake8, pre-commit, {pypy37,pypy38,py37,py38,py39,py310}-tests, flake8, check-manifest, check-newsfragment, cov-report +envlist = cov-erase, pre-commit, {pypy37,pypy38,py37,py38,py39,py310}-tests, flake8, check-manifest, check-newsfragment, cov-report isolated_build=true skip_missing_envs = true -[testenv:flake8] -skip_install = True -deps = - flake8 -commands = - flake8 src/towncrier/ - [testenv:pre-commit] skip_install = True deps = pre-commit From baba219d575c1d3533ad12f78a6cdda25690e000 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 11 Apr 2022 07:52:32 +0200 Subject: [PATCH 2/4] Add newsfragment --- src/towncrier/newsfragments/381.misc.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/towncrier/newsfragments/381.misc.rst diff --git a/src/towncrier/newsfragments/381.misc.rst b/src/towncrier/newsfragments/381.misc.rst new file mode 100644 index 00000000..e69de29b From aff21dd6e8856aeb4cad33dee46ff7a1d1c5a20b Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 11 Apr 2022 07:53:51 +0200 Subject: [PATCH 3/4] Remove stray exclude --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e482e48..cc1ca28d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,6 @@ repos: hooks: - id: flake8 language_version: python3.10 - exclude: docs/code_examples - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 From d8499255fb0292277a6273f6cafd2ac975cd1c30 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 11 Apr 2022 09:10:59 +0200 Subject: [PATCH 4/4] trigger ci