Skip to content

Commit

Permalink
Move all linters to pre-commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sallner committed Sep 21, 2023
1 parent 1aa25a1 commit 813b906
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 51 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
pull_request:
push:
branches: [master]

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]
- uses: pre-commit-ci/[email protected]
if: always()
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- ["macos", "macos-11"]
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
Expand All @@ -32,10 +31,8 @@ jobs:
- ["3.9", "docs"]
- ["3.9", "coverage"]
exclude:
- { os: ["windows", "windows-latest"], config: ["3.9", "lint"] }
- { os: ["windows", "windows-latest"], config: ["3.9", "docs"] }
- { os: ["windows", "windows-latest"], config: ["3.9", "coverage"] }
- { os: ["macos", "macos-11"], config: ["3.9", "lint"] }
- { os: ["macos", "macos-11"], config: ["3.9", "docs"] }
- { os: ["macos", "macos-11"], config: ["3.9", "coverage"] }
# macOS/Python 3.11+ is set up for universal2 architecture
Expand Down
33 changes: 32 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
ci:
autofix_prs: true

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.6.2
rev: "v2.6.2"
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/pycqa/isort
rev: "5.12.0"
hooks:
- id: isort
- repo: https://github.com/PyCQA/docformatter
rev: "v1.7.5"
hooks:
- id: docformatter
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: "v2.0.2"
hooks:
- id: autopep8
args: [--in-place, --aggressive, --aggressive]
- repo: https://github.com/PyCQA/flake8
rev: "6.1.0"
hooks:
- id: flake8
additional_dependencies:
- flake8-coding
- flake8-debugger
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
- repo: https://github.com/mgedmin/check-python-versions
rev: "0.21.3"
hooks:
- id: check-python-versions
2 changes: 2 additions & 0 deletions src/OFS/DTMLDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ class DTMLDocument(PropertyManager, DTMLMethod):

# Replace change_dtml_methods by change_dtml_documents
__ac_permissions__ = tuple([
# fmt: off
(perms[0] == change_dtml_methods) and # NOQA: W504
(change_dtml_documents, perms[1]) or perms
# fmt: on
for perms in DTMLMethod.__ac_permissions__])

def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
Expand Down
5 changes: 4 additions & 1 deletion src/Shared/DC/Scripts/Signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ def __init__(self, varnames=(), argcount=-1):
def __eq__(self, other):
if not isinstance(other, FuncCode):
return False
# fmt: off
return ((self.co_argcount, self.co_varnames) == # NOQA: W504
(other.co_argcount, other.co_varnames))
# fmt: on

def __lt__(self, other):
if not isinstance(other, FuncCode):
return False
# fmt: off
return ((self.co_argcount, self.co_varnames) < # NOQA: W504
(other.co_argcount, other.co_varnames))

# fmt: on

def _setFuncSignature(self, defaults=None, varnames=(), argcount=-1):
# This is meant to be imported directly into a class.
Expand Down
8 changes: 4 additions & 4 deletions src/ZPublisher/HTTPRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,16 @@ def processInputs(
hasattr=hasattr,
getattr=getattr,
setattr=setattr):
"""Process request inputs
"""Process request inputs.
See the `Zope Developer Guide Object Publishing chapter
<https://zope.readthedocs.io/en/latest/zdgbook/ObjectPublishing.html>`_
See the
`Zope Developer Guide Object Publishing chapter <https://zope.readthedocs.io/en/latest/zdgbook/ObjectPublishing.html>`_
for a detailed explanation in the section `Marshalling Arguments from
the Request`.
We need to delay input parsing so that it is done under
publisher control for error handling purposes.
"""
""" # noqa: E501
response = self.response
environ = self.environ
method = environ.get('REQUEST_METHOD', 'GET')
Expand Down
43 changes: 1 addition & 42 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[tox]
minversion = 3.18
envlist =
lint
py37
py38
py39
Expand Down Expand Up @@ -39,47 +38,7 @@ deps =
pre-commit
commands_pre =
commands =
pre-commit run --all-files --show-diff-on-failure

[testenv:autopep8]
basepython = python3.8
skip_install = true
deps =
-cconstraints.txt
autopep8
docformatter
commands =
autopep8 --verbose --in-place --recursive --aggressive --aggressive {toxinidir}/src setup.py
docformatter --in-place --recursive {toxinidir}/src setup.py

[testenv:lint]
basepython = python3
commands_pre =
mkdir -p {toxinidir}/parts/flake8
allowlist_externals =
mkdir
commands =
isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py
flake8 {toxinidir}/src {toxinidir}/setup.py
check-manifest
check-python-versions
deps =
check-manifest
check-python-versions
flake8
isort
# Useful flake8 plugins that are Python and Plone specific:
flake8-coding
flake8-debugger
mccabe

[testenv:isort-apply]
basepython = python3
commands_pre =
deps =
isort
commands =
isort {toxinidir}/src {toxinidir}/setup.py []
pre-commit run {posargs} --all-files

[testenv:docs]
basepython = python3
Expand Down

0 comments on commit 813b906

Please sign in to comment.