From f5240a55898778d5c7c9d9740c67076aa74b4f5c Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 00:32:25 +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 69453ed..1e79c57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,3 +106,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 3836c5e..3e06b7e 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 de7df05..fe52801 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,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] @@ -66,3 +67,8 @@ addopts = "--cov=dakara_feeder" [tool.isort] profile = "black" + +[tool.ruff] +select = ["E", "F", "W", "B"] +line-length = 88 +ignore = [] From bae99013dbe80585a09f3bc0394fa67615602d06 Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 00:33:10 +0100 Subject: [PATCH 2/5] fix uses of mutable default parameter reported by the bugbear checks --- src/dakara_feeder/directory.py | 4 ++-- src/dakara_feeder/subtitle/parsing.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dakara_feeder/directory.py b/src/dakara_feeder/directory.py index 6491a84..914ba27 100644 --- a/src/dakara_feeder/directory.py +++ b/src/dakara_feeder/directory.py @@ -139,11 +139,11 @@ class SongPaths: others (list of path.Path): Paths of other files. """ - def __init__(self, video, audio=None, subtitle=None, others=[]): + def __init__(self, video, audio=None, subtitle=None, others=None): self.video = video self.audio = audio self.subtitle = subtitle - self.others = others + self.others = [] if others is None else others def __eq__(self, other): return self.__hash__() == other.__hash__() diff --git a/src/dakara_feeder/subtitle/parsing.py b/src/dakara_feeder/subtitle/parsing.py index d7f4cf8..d23e5fa 100644 --- a/src/dakara_feeder/subtitle/parsing.py +++ b/src/dakara_feeder/subtitle/parsing.py @@ -26,8 +26,8 @@ class SubtitleParser(ABC): object or the full text of the lyrics. """ - def __init__(self, content={}): - self.content = content + def __init__(self, content=None): + self.content = {} if content is None else content @classmethod @abstractmethod From e2f3010361d3c55dfe33914d8e6c0f25e00c0ba5 Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 01:09:21 +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 abbd0dc..0000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -ignore = E203, W503 From 221e01f277bbf230633a0ec83b987079d9d3bb1a Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 15:07:12 +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 fe52801..6af459f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,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 99259d55614dd607c610f0e4ed661a667a533e40 Mon Sep 17 00:00:00 2001 From: odrling Date: Sat, 16 Mar 2024 15:10:28 +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 6af459f..b3bfb5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,8 @@ addopts = "--cov=dakara_feeder" profile = "black" [tool.ruff] -select = ["E", "F", "W", "B"] line-length = 88 + +[tool.ruff.lint] +select = ["E", "F", "W", "B"] ignore = []