Skip to content

Commit

Permalink
Add linting to CI via pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Feb 1, 2023
1 parent bd1c5cd commit 957e20b
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max_line_length = 88
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ It should describe the change to be made.
Most PRs will require an issue number. Trivial changes, like fixing a typo,
do not need an issue.
-->
-->
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint

on: [push, pull_request, workflow_dispatch]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.0
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: [--target-version=py37, --skip-string-normalization]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: [--profile=black]

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [flake8-2020]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

ci:
autoupdate_schedule: quarterly
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ Affirmer's express Statement of Purpose.
CC0 or use of the Work.

For more information, please see
<https://creativecommons.org/publicdomain/zero/1.0/>
<https://creativecommons.org/publicdomain/zero/1.0/>
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ help:
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " check to run a check for frequent markup errors"
@echo " lint to lint all the files"
@echo " versions to update release cycle after changing release-cycle.json"

.PHONY: clean
Expand Down Expand Up @@ -183,6 +184,11 @@ check: ensure-venv
# Ignore the tools and venv dirs and check that the default role is not used.
$(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role

.PHONY: lint
lint: venv
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
$(VENVDIR)/bin/python3 -m pre_commit run --all-files

.PHONY: serve
serve:
@echo "The 'serve' target was removed, use 'htmlview' instead" \
Expand Down
5 changes: 3 additions & 2 deletions _extensions/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def role(name, rawtext, text, lineno, inliner, _options=None, _content=None):
if text.startswith('!'):
node = nodes.literal(rawtext, text[1:])
else:
node = nodes.reference(rawtext, '', nodes.literal(rawtext, text),
refuri=url, internal=False)
node = nodes.reference(
rawtext, '', nodes.literal(rawtext, text), refuri=url, internal=False
)
return [node], []

return role
1 change: 0 additions & 1 deletion developer-workflow/lang-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ to inform others who may propose a similar language change in the future.
.. _Ideas Discourse category: https://discuss.python.org/c/ideas/6
.. _Status Quo Wins a Stalemate: https://www.curiousefficiency.org/posts/2011/02/status-quo-wins-stalemate.html
.. _Justifying Python Language Changes: https://www.curiousefficiency.org/posts/2011/02/justifying-python-language-changes.html

0 comments on commit 957e20b

Please sign in to comment.