From 3cb179db4597c669063e79c872db2007cded6c28 Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 00:38:24 +0100 Subject: [PATCH 1/5] setup ruff as a flake8 replacement ruff runs pretty fast, which is nice when used as a pre-commit hook. It also implements more checks that can be selected as needed, in this commit I add the bugbear (B) checks which were not present in the previous configuration. --- .github/workflows/ci.yml | 3 +++ .pre-commit-config.yaml | 6 +++--- pyproject.toml | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7361b708..30f58d86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,3 +122,6 @@ jobs: - name: Run style checks run: python -m black . --check + + - name: Run ruff linter + run: python -m ruff check . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3836c5e3..3e06b7e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,8 +23,8 @@ repos: entry: black . --check language: system pass_filenames: false - - id: flake8-check - name: Check PEP8 - entry: flake8 + - id: ruff-check + name: Run ruff linter + entry: ruff check . language: system pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index dbed3ca9..bfea8a9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ dev = [ "pre-commit>=2.20.0,<2.21.0", "pytest-cov>=4.0.0,<4.1.0", "pytest>=7.2.0,<7.3.0", + "ruff", ] [project.urls] @@ -71,3 +72,8 @@ addopts = "--cov=dakara_player" [tool.isort] profile = "black" + +[tool.ruff] +select = ["E", "F", "W", "B"] +line-length = 88 +ignore = [] From 6fc18a2dda62e008482be8ee3f1aa612babdf47e Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 00:42:30 +0100 Subject: [PATCH 2/5] fix use of mutable default parameter reported by the bugbear checks --- tests/unit/test_media_player_mpv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_media_player_mpv.py b/tests/unit/test_media_player_mpv.py index 440a7006..fd7ea79e 100644 --- a/tests/unit/test_media_player_mpv.py +++ b/tests/unit/test_media_player_mpv.py @@ -698,7 +698,7 @@ def test_init(self): mpv_player, (mocked_player, _, _), _ = self.get_instance( {"mpv": {"key1": "value1"}} ) - self.assertEqual(getattr(mocked_player, "key1"), "value1") + self.assertEqual(mocked_player.key1, "value1") def test_play_invalid(self): """Test to play invalid action.""" From 3f32b9795992a8af862b8c5fbdacce8f638aa5fe Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 01:09:58 +0100 Subject: [PATCH 3/5] remove flake8 configuration file --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index abbd0dcd..00000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -ignore = E203, W503 From 158556bfaae59d1c94d037a0164df22be341f330 Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 15:07:55 +0100 Subject: [PATCH 4/5] lock ruff to version 0.3.x --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bfea8a9f..697f12ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ dev = [ "pre-commit>=2.20.0,<2.21.0", "pytest-cov>=4.0.0,<4.1.0", "pytest>=7.2.0,<7.3.0", - "ruff", + "ruff>=0.3.0,<0.4.0", ] [project.urls] From 19c69d867789690e98b3973bc0e71f131c29700f Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 15:09:41 +0100 Subject: [PATCH 5/5] ruff: move linter settings to lint subsection --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 697f12ea..d6a23694 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,8 @@ addopts = "--cov=dakara_player" profile = "black" [tool.ruff] -select = ["E", "F", "W", "B"] line-length = 88 + +[tool.ruff.lint] +select = ["E", "F", "W", "B"] ignore = []