diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index caeedfa..a280a75 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -138,7 +138,7 @@ check-merge-request: junit: results.xml allow_failure: true -# Format anything python with python-black +# Format anything python with ruff # python-black: extends: @@ -147,9 +147,9 @@ python-black: before_script: - python3 -m venv venv - source venv/bin/activate - - pip3 install black + - pip3 install ruff script: - - black --check --diff . proto/ei-scanner + - ruff format --check --diff . proto/ei-scanner # Lint with Ruff # diff --git a/.gitlab-ci/ci.template b/.gitlab-ci/ci.template index 7e7cad5..7386b6a 100644 --- a/.gitlab-ci/ci.template +++ b/.gitlab-ci/ci.template @@ -144,7 +144,7 @@ check-merge-request: junit: results.xml allow_failure: true -# Format anything python with python-black +# Format anything python with ruff # python-black: extends: @@ -153,9 +153,9 @@ python-black: before_script: - python3 -m venv venv - source venv/bin/activate - - pip3 install black + - pip3 install ruff script: - - black --check --diff . proto/ei-scanner + - ruff format --check --diff . proto/ei-scanner # Lint with Ruff # diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7db1b72..412c714 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,16 +8,13 @@ repos: - id: check-symlinks - id: no-commit-to-branch args: ['--branch', 'main'] -- repo: https://github.com/psf/black - rev: 23.11.0 - hooks: - - id: black - args: ['--check', '--diff', '.', 'proto/ei-scanner'] - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.1.7 hooks: - id: ruff args: ['--ignore=E741,E501', '.', 'proto/ei-scanner'] + - id: ruff-format + args: ['.', 'proto/ei-scanner'] - repo: local hooks: - id: ci-fairy-generate-template diff --git a/meson.build b/meson.build index 092a0e9..e615e3b 100644 --- a/meson.build +++ b/meson.build @@ -113,18 +113,14 @@ subdir('tools') subdir('test') subdir('doc') -black = find_program('black', required: false) -if black.found() - test('python-black', black, - args: ['--check', meson.project_source_root(), meson.project_source_root() / 'proto' / 'ei-scanner'], - suite: 'python', - ) -endif - ruff = find_program('ruff', required: false) if ruff.found() test('python-ruff', ruff, args: ['check', '--ignore=E741,E501', meson.project_source_root(), meson.project_source_root() / 'proto' / 'ei-scanner'], suite: 'python', ) + test('python-ruff-format', ruff, + args: ['format', meson.project_source_root(), meson.project_source_root() / 'proto' / 'ei-scanner'], + suite: 'python', + ) endif diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..d189b2e --- /dev/null +++ b/ruff.toml @@ -0,0 +1,2 @@ +# Same as Black. +line-length = 88 diff --git a/test/test_protocol.py b/test/test_protocol.py index f814533..216572d 100644 --- a/test/test_protocol.py +++ b/test/test_protocol.py @@ -459,9 +459,7 @@ class TestEiProtocol: invalid_type = 4 try: EiHandshake.EiContextType(invalid_type) - assert ( - False - ), f"{invalid_type} should not be a valid ContextType, this test needs an update" + assert False, f"{invalid_type} should not be a valid ContextType, this test needs an update" except ValueError: pass @@ -1101,7 +1099,9 @@ class TestEiProtocol: @attr.s class Status: - pointers: dict[InterfaceName, Interface] = attr.ib(default=attr.Factory(dict)) # type: ignore + pointers: dict[InterfaceName, Interface] = attr.ib( + default=attr.Factory(dict) + ) # type: ignore all_caps: int = attr.ib(default=0) status = Status()