diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07bce73c..e30fd711 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,10 +4,8 @@ ci: skip: - check-dev-files - mypy - - prettier - pyright - self-check - - taplo repos: - repo: meta @@ -16,7 +14,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.5 + rev: v0.6.3 hooks: - id: ruff args: [--fix] @@ -70,10 +68,10 @@ repos: hooks: - id: prettier - - repo: https://github.com/ComPWA/mirrors-taplo - rev: v0.8.1 + - repo: https://github.com/ComPWA/taplo-pre-commit + rev: v0.9.3 hooks: - - id: taplo + - id: taplo-format - repo: https://github.com/pappasam/toml-sort rev: v0.23.1 @@ -83,12 +81,12 @@ repos: exclude: (?x)^(labels/.*\.toml)$ - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.13.0 + rev: v8.13.3 hooks: - id: cspell - repo: https://github.com/editorconfig-checker/editorconfig-checker.python - rev: 2.7.3 + rev: 3.0.3 hooks: - id: editorconfig-checker name: editorconfig @@ -109,6 +107,6 @@ repos: - python - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.374 + rev: v1.1.379 hooks: - id: pyright diff --git a/src/compwa_policy/.template/.cspell.json b/src/compwa_policy/.template/.cspell.json index c38ef86b..38a60164 100644 --- a/src/compwa_policy/.template/.cspell.json +++ b/src/compwa_policy/.template/.cspell.json @@ -1,6 +1,11 @@ { "version": "0.2", - "enableFiletypes": ["git-commit", "github-actions-workflow", "julia", "jupyter"], + "enableFiletypes": [ + "git-commit", + "github-actions-workflow", + "julia", + "jupyter" + ], "flagWords": [ "analyse", "colour", diff --git a/src/compwa_policy/check_dev_files/precommit.py b/src/compwa_policy/check_dev_files/precommit.py index 23890321..9c4b8d96 100644 --- a/src/compwa_policy/check_dev_files/precommit.py +++ b/src/compwa_policy/check_dev_files/precommit.py @@ -63,6 +63,7 @@ def __repo_sort_key(repo: Repo) -> tuple[int, str]: "isort", "prettier", "taplo", + "taplo-format", "toml-sort", } if hook_id in formatter_hooks: @@ -129,12 +130,17 @@ def get_local_hooks(config: PrecommitConfig) -> list[str]: def get_non_functional_hooks(config: PrecommitConfig) -> list[str]: + skipped_hooks = { + "check-jsonschema", + "pyright", + "taplo", + } return [ hook["id"] for repo in config["repos"] for hook in repo["hooks"] if repo["repo"] - if hook["id"] in __get_skipped_hooks(config) + if hook["id"] in skipped_hooks ] @@ -166,17 +172,6 @@ def _update_conda_environment(precommit: Precommit) -> None: raise PrecommitError(msg) -def __get_skipped_hooks(config: PrecommitConfig) -> set[str]: - skipped_hooks = { - "check-jsonschema", - "pyright", - "taplo", - } - if __has_prettier_v4alpha(config): - skipped_hooks.add("prettier") - return skipped_hooks - - def __has_prettier_v4alpha(config: PrecommitConfig) -> bool: repo = find_repo(config, search_pattern=r"^.*/mirrors-prettier$") if repo is None: diff --git a/src/compwa_policy/check_dev_files/toml.py b/src/compwa_policy/check_dev_files/toml.py index b134c3cf..2f7a9803 100644 --- a/src/compwa_policy/check_dev_files/toml.py +++ b/src/compwa_policy/check_dev_files/toml.py @@ -36,6 +36,7 @@ def main(precommit: ModifiablePrecommit) -> None: with Executor() as do: do(_rename_taplo_config) do(_update_taplo_config) + do(_rename_precommit_url, precommit) do(_update_precommit_repo, precommit) do(_update_tomlsort_config) do(_update_tomlsort_hook, precommit) @@ -121,11 +122,32 @@ def _update_taplo_config() -> None: raise PrecommitError(msg) +def _rename_precommit_url(precommit: ModifiablePrecommit) -> None: + mirrors_repo_with_idx = precommit.find_repo_with_index(r"^.*/mirrors-taplo$") + rev = "" + if mirrors_repo_with_idx is not None: + idx, repo = mirrors_repo_with_idx + rev = repo["rev"] + precommit.document["repos"].pop(idx) + precommit.changelog.append("Renamed mirrors-taplo repo to taplo-pre-commit") + expected_hook = Repo( + repo="https://github.com/ComPWA/taplo-pre-commit", + rev=rev, + hooks=[Hook(id="taplo-format")], + ) + precommit.update_single_hook_repo(expected_hook) + + def _update_precommit_repo(precommit: ModifiablePrecommit) -> None: + mirrors_repo_with_idx = precommit.find_repo_with_index(r"^.*/mirrors-taplo$") + if mirrors_repo_with_idx is not None: + idx, _ = mirrors_repo_with_idx + precommit.document["repos"].pop(idx) + precommit.changelog.append("Renamed mirrors-taplo repo to taplo-pre-commit") expected_hook = Repo( - repo="https://github.com/ComPWA/mirrors-taplo", + repo="https://github.com/ComPWA/taplo-pre-commit", rev="", - hooks=[Hook(id="taplo")], + hooks=[Hook(id="taplo-format")], ) precommit.update_single_hook_repo(expected_hook) diff --git a/src/compwa_policy/set_nb_cells.py b/src/compwa_policy/set_nb_cells.py index 3b5d87f7..9c4d4d43 100644 --- a/src/compwa_policy/set_nb_cells.py +++ b/src/compwa_policy/set_nb_cells.py @@ -166,7 +166,7 @@ def _insert_autolink_concat(filename: str) -> None: return new_cell = nbformat.v4.new_markdown_cell(expected_cell_content) del new_cell["id"] # following nbformat_minor = 4 - notebook["cells"].insert(cell_id, new_cell) # noqa: B909 + notebook["cells"].insert(cell_id, new_cell) nbformat.validate(notebook) nbformat.write(notebook, filename) return diff --git a/src/compwa_policy/utilities/precommit/struct.py b/src/compwa_policy/utilities/precommit/struct.py index fbc18b24..5f316829 100644 --- a/src/compwa_policy/utilities/precommit/struct.py +++ b/src/compwa_policy/utilities/precommit/struct.py @@ -1,4 +1,4 @@ -# noqa: D100 +# noqa: A005, D100 from __future__ import annotations import sys diff --git a/src/compwa_policy/utilities/pyproject/_struct.py b/src/compwa_policy/utilities/pyproject/_struct.py index bf69e830..488c13c0 100644 --- a/src/compwa_policy/utilities/pyproject/_struct.py +++ b/src/compwa_policy/utilities/pyproject/_struct.py @@ -1,3 +1,4 @@ +# noqa: A005 """This module is hidden Sphinx can't handle `typing.TypedDict` with hyphens. See https://github.com/sphinx-doc/sphinx/issues/11039.