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 2e5d9cb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 44 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()
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
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 2e5d9cb

Please sign in to comment.