From 7f1c0ab0a78ba65b98127fcd8e101b89391d80dd Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Thu, 2 Jan 2025 14:49:43 +0100 Subject: [PATCH] Replace Black with Ruff-format (#458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove line-length, somehow already 88 characters, Black’s default CI: Move format check to Ruff job --- .gitlab-ci.yml | 9 +-------- .pre-commit-config.yaml | 5 +---- docs/contributing/index.md | 4 ++-- pyproject.toml | 1 - tests/unit/test_public_key.py | 5 ++++- tests/unit/wot/test_idty_tools.py | 4 +++- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 90ae8da1..7178b92d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,14 +56,6 @@ build: paths: - ${PRE_COMMIT_HOME} -black: - extends: - - .code_changes - - .pre-commit - stage: checks - script: - - pre-commit run -a black - mypy: extends: - .code_changes @@ -95,6 +87,7 @@ ruff: stage: checks script: - pre-commit run -a ruff + - pre-commit run -a ruff-format .tests: extends: .changes diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7497ee95..7748456d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,10 +15,7 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] -- repo: https://github.com/psf/black - rev: 24.10.0 - hooks: - - id: black + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.14.1 hooks: diff --git a/docs/contributing/index.md b/docs/contributing/index.md index 0bf5385c..c8e03cd1 100644 --- a/docs/contributing/index.md +++ b/docs/contributing/index.md @@ -88,10 +88,10 @@ In case you want to commit while the hooks are failing, run the following to [sk git commit -m "msg" --no-verify/-n ``` -To manually run one of the tool above, run (eg for `black`): +To manually run one of the tool above, run (eg for `ruff-format`): ```bash -pre-commit run --all-files black +pre-commit run --all-files ruff-format ``` To run all checks on all files: diff --git a/pyproject.toml b/pyproject.toml index 86fc39dc..60e4edd6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ classifiers = [ ignore_missing_imports = true [tool.ruff] -line-length = 101 target-version = "py39" lint.select = ["F", "W", "I", "UP", "YTT", "B", "A", "DTZ", "T10", "EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID", "PL", diff --git a/tests/unit/test_public_key.py b/tests/unit/test_public_key.py index e90b8bd9..46fcdeb4 100644 --- a/tests/unit/test_public_key.py +++ b/tests/unit/test_public_key.py @@ -127,7 +127,10 @@ def test_gen_pubkey_checksum(pubkey, checksum): assert f"{pubkey}:{checksum}" == public_key.gen_pubkey_checksum(pubkey) assert ( f"{pubkey[:SHORT_PUBKEY_SIZE]}…:{checksum}" - == public_key.gen_pubkey_checksum(pubkey, short=True) + == public_key.gen_pubkey_checksum( + pubkey, + short=True, + ) ) assert f"{pubkey[:14]}…:{checksum}" == public_key.gen_pubkey_checksum( pubkey, diff --git a/tests/unit/wot/test_idty_tools.py b/tests/unit/wot/test_idty_tools.py index 446bd482..4451994b 100644 --- a/tests/unit/wot/test_idty_tools.py +++ b/tests/unit/wot/test_idty_tools.py @@ -107,7 +107,8 @@ def test_display_alternate_ids(): id_claudius_maximus, ] - expected = "+------------------+--------------------------------------------+--------------+\n\ + expected = ( + "+------------------+--------------------------------------------+--------------+\n\ | uid | public key | timestamp |\n\ +==================+============================================+==============+\n\ | moul-test | 5B8iMAzq1dNmFe3ZxFTBQkqhq4fsztg1gZvxHXCk1X | 167750-0000A |\n\ @@ -119,6 +120,7 @@ def test_display_alternate_ids(): | Claudius Maximus | 6upqFiJ66WV6N3bPc8x8y7rXT3syqKRmwnVyunCtEj | 7334-002A45E |\n\ | | 7o:7xo | |\n\ +------------------+--------------------------------------------+--------------+" + ) table = idty_tools.display_alternate_ids(ids_list) assert expected == table.draw() -- GitLab