Skip to content

Commit

Permalink
Run isort, autopep8 and flake8 in pre-commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
icemac committed Aug 16, 2024
1 parent b004833 commit 6c99bff
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: pre-commit

on:
pull_request:
push:
branches:
- master
jobs:
pre-commit:
name: pre-commit linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
- uses: pre-commit-ci/[email protected]
if: always()
with:
msg: Apply pre-commit code formatting
21 changes: 19 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
minimum_pre_commit_version: '3.6'
repos:
- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: isort
- repo: https://github.com/hhatto/autopep8
rev: "v2.3.1"
hooks:
- id: autopep8
args: [--in-place, --aggressive, --aggressive]
- repo: https://github.com/asottile/pyupgrade
rev: v2.6.2
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py38-plus]
- repo: https://github.com/PyCQA/flake8
rev: "6.1.0"
hooks:
- id: flake8
additional_dependencies:
- flake8-coding == 1.3.2
- flake8-debugger == 4.1.2
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"light_logo": "Zope.svg",
"dark_logo": "Zope.svg",
"light_css_variables": {
# "color-brand-content": "#00AAD4", # Too light for white background
# "color-brand-content": "#00AAD4", # Too light for white background
},
"dark_css_variables": {
"color-brand-content": "#00AAD4",
Expand Down
9 changes: 4 additions & 5 deletions src/ZPublisher/BaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,10 @@ def ensure_publishable(self, obj, for_call=False):
# a tuple of allowed request methods
request_method = (getattr(self, "environ", None)
and self.environ.get("REQUEST_METHOD"))
if (request_method is None # noqa: E271
or request_method.upper() not in publishable):
raise Forbidden(
f"The object at {url} does not support "
f"{request_method} requests")
if (request_method is None # noqa: E271
or request_method.upper() not in publishable):
raise Forbidden(f"The object at {url} does not support "
f"{request_method} requests")
return
# ``publishable`` is ``None``

Expand Down

0 comments on commit 6c99bff

Please sign in to comment.