From ba90047a210a2a1eed57cea5a84c8a4b1de6e61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sun, 14 Apr 2024 15:38:16 +0100 Subject: [PATCH] Migrate to ruff --- .github/workflows/pythonpackage.yml | 4 ++-- fastbencode/tests/test_bencode.py | 2 +- pyproject.toml | 8 +++++--- setup.py | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 557d577..e67f739 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -21,10 +21,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip cython - pip install -U pip flake8 + pip install -U pip ruff - name: Style checks run: | - python -m flake8 + python -m ruff check . - name: Test suite run run: | python -m unittest fastbencode.tests.test_suite diff --git a/fastbencode/tests/test_bencode.py b/fastbencode/tests/test_bencode.py index 61cd8b5..67f7d5c 100644 --- a/fastbencode/tests/test_bencode.py +++ b/fastbencode/tests/test_bencode.py @@ -341,7 +341,7 @@ def test_unknown_object(self): self.assertRaises(ValueError, self.module.bdecode, b'relwjhrlewjh') def test_unsupported_type(self): - self._run_check_error(TypeError, float(1.5)) + self._run_check_error(TypeError, 1.5) self._run_check_error(TypeError, None) self._run_check_error(TypeError, lambda x: x) self._run_check_error(TypeError, object) diff --git a/pyproject.toml b/pyproject.toml index f2abffa..81ea820 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,10 @@ include-package-data = false version = {attr = "fastbencode.__version__"} [tool.ruff] +target-version = "py37" +line-length = 79 + +[tool.ruff.lint] select = [ "ANN", "D", @@ -50,7 +54,6 @@ select = [ "I", "UP", ] -target-version = "py37" ignore = [ "ANN001", "ANN002", @@ -65,7 +68,6 @@ ignore = [ "D105", "D107", ] -line-length = 79 -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" diff --git a/setup.py b/setup.py index d9436af..1b92be8 100755 --- a/setup.py +++ b/setup.py @@ -28,8 +28,8 @@ cython_version_info = Version(cython_version) if cython_version_info < Version(minimum_cython_version): print("Version of Cython is too old. " - "Current is {}, need at least {}.".format( - cython_version, minimum_cython_version)) + f"Current is {cython_version}, " + f"need at least {minimum_cython_version}.") print("If the .c files are available, they will be built," " but modifying the .pyx files will not rebuild them.") have_cython = False