From 1b90d930db31ded3b025087ece8779f06c4d63a5 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:05:14 +0300 Subject: [PATCH 1/3] Replace Flake8 with Ruff --- .flake8 | 2 -- .pre-commit-config.yaml | 31 +++++++------------------------ pyproject.toml | 32 +++++++++++++++++++++++++++++--- python_docs_theme/__init__.py | 2 +- 4 files changed, 37 insertions(+), 30 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 2bcd70e3..00000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70b4e19a..4837461a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -39,7 +22,7 @@ repos: - id: trailing-whitespace - 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] diff --git a/pyproject.toml b/pyproject.toml index 9e46db68..9e0a47fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/python_docs_theme/__init__.py b/python_docs_theme/__init__.py index 77476754..7b9df306 100644 --- a/python_docs_theme/__init__.py +++ b/python_docs_theme/__init__.py @@ -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( From 2f1bf7c966a09e06f20415657be417f6b1e3d2c7 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:08:48 +0300 Subject: [PATCH 2/3] Add check-jsonschema to lint YAML and actionlint for GitHub Actions --- .pre-commit-config.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4837461a..42cd35e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,17 @@ 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.8.0 hooks: From fce4eb415c5f3de7ebebfeed872616180f936632 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:09:27 +0300 Subject: [PATCH 3/3] Fix shellcheck SC2046: Quote this to prevent word splitting --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1b58d3ed..70182f02 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy