Skip to content

Commit

Permalink
chore: replace black by ruff formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
GabDug committed Feb 18, 2024
1 parent 4b1ac9e commit c8131ec
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 101 deletions.
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ repos:
- id: check-merge-conflict
- id: fix-byte-order-marker

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

- rev: v0.2.1
- rev: v0.2.2
repo: https://github.com/astral-sh/ruff-pre-commit
hooks:
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
[![Python version](https://img.shields.io/pypi/pyversions/sync-pre-commit-lock.svg)](https://pypi.python.org/pypi/sync-pre-commit-lock)
[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
[![Ruff](https://img.shields.io/badge/ruff-lint-red)](https://github.com/charliermarsh/ruff)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

PDM and Poetry plugin to sync your pre-commit versions with your lockfile and automatically install pre-commit hooks.

Expand Down
108 changes: 25 additions & 83 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ write_to = "sync_pre_commit_lock/_version.py"
write_template = "__version__: str = \"{}\"\n"

[tool.pdm.scripts]
fmt = {cmd="black .", help="Run black formatter"}
fmt = {cmd="ruff format .", help="Run ruff formatter"}
lint-mypy = {cmd="mypy src", help="Run mypy type checker"}
# XXX(dugab): run mypy on tests as well
lint-ruff = {cmd="ruff .", help="Run ruff linter"}
Expand All @@ -72,7 +72,6 @@ test-cov = {cmd="pytest --junitxml=junit/test-results.xml --cov --cov-report=xml
[tool.pdm.dev-dependencies]
dev = [
"PyYAML>=6.0",
"black>=23.12.0",
"mypy>=1.4.1",
"ruff>=0.0.275",
"types-PyYAML>=6.0.12.10",
Expand All @@ -84,7 +83,7 @@ dev = [
]

[tool.ruff]
line-length = 140
line-length = 120
respect-gitignore = true

[tool.ruff.lint]
Expand All @@ -99,9 +98,6 @@ strict = true
module = "strictyaml"
ignore_missing_imports = true

[tool.black]
line-length = 120

[tool.pytest.ini_options]
minversion = "7.0"
testpaths = ["tests"]
Expand Down
6 changes: 2 additions & 4 deletions src/sync_pre_commit_lock/actions/sync_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def get_pre_commit_repo_new_version(
return None

self.printer.debug(
f"Found mapping between pre-commit hook `{pre_commit_config_repo.repo}` and locked package"
f" `{locked_package.name}`."
f"Found mapping between pre-commit hook `{pre_commit_config_repo.repo}` and locked package `{locked_package.name}`."
)
formatted_rev = mapping_db_repo_info["rev"].replace("${rev}", str(locked_package.version))
if formatted_rev != pre_commit_config_repo.rev:
Expand All @@ -96,8 +95,7 @@ def get_pre_commit_repo_new_version(
return formatted_rev

self.printer.debug(
f"Pre-commit hook {pre_commit_config_repo.repo} version already matches the version from the lockfile"
" package."
f"Pre-commit hook {pre_commit_config_repo.repo} version already matches the version from the lockfile package."
)
return None

Expand Down

0 comments on commit c8131ec

Please sign in to comment.