Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX: switch to black pre-commit hook #209

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/repoma/check_dev_files/black.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/test_precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}


Expand Down
Loading