From a8cc64a87930db3795cedaa8a8e72e5ffe266d6c Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:46:28 +0100 Subject: [PATCH] DX: switch to black pre-commit hook --- .pre-commit-config.yaml | 2 +- src/repoma/check_dev_files/black.py | 7 ++++++- tests/utilities/test_precommit.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b1bbbd3..a4b73327 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: language: python files: ^\.pre\-commit\-(config|hooks)\.yaml$ - - repo: https://github.com/psf/black + - repo: https://github.com/psf/black-pre-commit-mirror rev: 23.9.1 hooks: - id: black diff --git a/src/repoma/check_dev_files/black.py b/src/repoma/check_dev_files/black.py index e27b7855..21b51cb4 100644 --- a/src/repoma/check_dev_files/black.py +++ b/src/repoma/check_dev_files/black.py @@ -30,6 +30,11 @@ def main(has_notebooks: bool) -> None: executor = Executor() executor(_remove_outdated_settings) executor(_update_black_settings) + executor( + remove_precommit_hook, + hook_id="black", + repo_url="https://github.com/psf/black", + ) executor(_update_precommit_repo, has_notebooks) executor(add_extension_recommendation, "ms-python.black-formatter") executor(set_setting, {"black-formatter.importStrategy": "fromEnvironment"}) @@ -81,7 +86,7 @@ def _update_black_settings() -> None: def _update_precommit_repo(has_notebooks: bool) -> None: expected_hook = CommentedMap( - repo="https://github.com/psf/black", + repo="https://github.com/psf/black-pre-commit-mirror", hooks=[CommentedMap(id="black")], ) if has_notebooks: diff --git a/tests/utilities/test_precommit.py b/tests/utilities/test_precommit.py index acd9115e..45abe850 100644 --- a/tests/utilities/test_precommit.py +++ b/tests/utilities/test_precommit.py @@ -52,7 +52,7 @@ def test_load_default(self): repo_names = {repo.repo for repo in config.repos} assert repo_names >= { "https://github.com/pre-commit/pre-commit-hooks", - "https://github.com/psf/black", + "https://github.com/psf/black-pre-commit-mirror", }