Skip to content

Commit

Permalink
Merge pull request #189 from hugovk/replace-flake8-with-ruff
Browse files Browse the repository at this point in the history
Replace Flake8 with Ruff and add more linting for GitHub Actions
  • Loading branch information
hugovk committed Apr 22, 2024
2 parents 26ca6d7 + fce4eb4 commit 9cda3a5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
--build-root ./build_root
--www-root ./www
--log-directory ./logs
--group $(id -g)
--group "$(id -g)"
--skip-cache-invalidation
--theme $(pwd)
--theme "$(pwd)"
--language en
--branch ${{ matrix.branch }}
- name: Show logs
Expand Down
42 changes: 18 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: ruff
args: [--exit-non-zero-on-fix]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
rev: 24.4.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
[flake8-2020, flake8-implicit-str-concat, flake8-logging]

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

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
Expand All @@ -38,8 +21,19 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.2
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/rhysd/actionlint
rev: v1.6.27
hooks:
- id: actionlint

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.7.0
rev: 1.8.0
hooks:
- id: pyproject-fmt
args: [--max-supported-python=3.13]
Expand Down
32 changes: 29 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ include = [
"python_docs_theme/",
]

[tool.isort]
add_imports = "from __future__ import annotations"
profile = "black"
[tool.ruff]
fix = true

[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"PGH", # pygrep-hooks
"PYI", # flake8-pyi
"RUF100", # unused noqa (yesqa)
"RUF022", # unsorted-dunder-all
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
]
ignore = [
"E203", # Whitespace before ':'
"E221", # Multiple spaces before operator
"E226", # Missing whitespace around arithmetic operator
"E241", # Multiple spaces after ','
]


[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
2 changes: 1 addition & 1 deletion python_docs_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _asset_hash(path: str) -> str:
def _add_asset_hashes(static: list[str], add_digest_to: list[str]) -> None:
for asset in add_digest_to:
index = static.index(asset)
static[index].filename = _asset_hash(asset) # type: ignore
static[index].filename = _asset_hash(asset) # type: ignore[attr-defined]


def _html_page_context(
Expand Down

0 comments on commit 9cda3a5

Please sign in to comment.