Browse Source

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.
pull/381/head
Hynek Schlawack 4 months ago
parent
commit
de70b1db1d
  1. 4
      .github/workflows/ci.yml
  2. 2
      .gitignore
  3. 19
      .pre-commit-config.yaml
  4. 2
      admin/check_tag_version_match.py
  5. 1
      bin/towncrier
  6. 2
      docs/Makefile
  7. 3
      docs/conf.py
  8. 2
      docs/configuration.rst
  9. 2
      setup.py
  10. 1
      src/towncrier/newsfragments/330.misc
  11. 2
      src/towncrier/newsfragments/367.doc.rst
  12. 2
      src/towncrier/newsfragments/369.feature.rst
  13. 2
      src/towncrier/test/test_build.py
  14. 9
      tox.ini

4
.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

2
.gitignore vendored

@ -22,4 +22,4 @@ apidocs/
.coverage.*
.vscode
.idea
.python-version
.python-version

19
.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

2
admin/check_tag_version_match.py

@ -24,7 +24,7 @@ if not run_version.startswith(TAG_PREFIX):
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}'")

1
bin/towncrier

@ -1,4 +1,5 @@
#! /usr/bin/env python3
# flake8: noqa
import sys
import os.path

2
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)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

3
docs/conf.py

@ -165,6 +165,3 @@ texinfo_documents = [
author, 'Towncrier', 'One line description of project.',
'Miscellaneous'),
]

2
docs/configuration.rst

@ -93,4 +93,4 @@ For example:
[[tool.towncrier.type]]
directory = "chore"
name = "Other Tasks"
showcontent = false
showcontent = false

2
setup.py

@ -5,7 +5,7 @@ from setuptools import setup, find_packages
# 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(

1
src/towncrier/newsfragments/330.misc

@ -1 +0,0 @@

2
src/towncrier/newsfragments/367.doc.rst

@ -1 +1 @@
Move docs too master branch and document custom fragment types.
Move docs too master branch and document custom fragment types.

2
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.
way to configure custom types.

2
src/towncrier/test/test_build.py

@ -670,7 +670,7 @@ class TestCli(TestCase):
)
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(

9
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

Loading…
Cancel
Save