From 95816c03b401d38d724447c07e419ba2aef663d1 Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Wed, 25 Sep 2024 16:53:55 +0200 Subject: [PATCH] Lint with Ruff instead of Flake8 --- .github/workflows/main.yml | 2 +- fimfarchive/fetchers/fimfiction2.py | 4 ++-- pyproject.toml | 9 ++++++++- tests/fetchers/test_directory.py | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 57bc455..7daf9e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: run: uv sync --all-extras --dev - name: Check styling - run: uv run flake8 --ignore=E123,E231,W291,W293 fimfarchive tests + run: uv run ruff check - name: Check types run: uv run mypy diff --git a/fimfarchive/fetchers/fimfiction2.py b/fimfarchive/fetchers/fimfiction2.py index 84c88d9..a86a65d 100644 --- a/fimfarchive/fetchers/fimfiction2.py +++ b/fimfarchive/fetchers/fimfiction2.py @@ -34,7 +34,7 @@ from jsonapi_client.document import Document from jsonapi_client.exceptions import DocumentError from jsonapi_client.resourceobject import ResourceObject -from fimfarchive import __version__ as VERSION +from fimfarchive import __version__ as version from fimfarchive.flavors import DataFormat, MetaFormat, MetaPurity, StorySource from fimfarchive.exceptions import ( @@ -164,7 +164,7 @@ class ApiClient: headers = { 'Accept-Encoding': 'gzip, deflate', 'Authorization': f'Bearer {token}', - 'User-Agent': f'fimfarchive/{VERSION}', + 'User-Agent': f'fimfarchive/{version}', } return Session( diff --git a/pyproject.toml b/pyproject.toml index fe6ed57..9654d96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,10 +22,10 @@ lz4 = ["lz4~=4.3"] [tool.uv] compile-bytecode = true dev-dependencies = [ - "flake8~=5.0", "mypy~=1.11", "pytest~=8.3", "requests-mock~=1.12", + "ruff~=0.6", "types-jmespath~=1.0", "types-requests~=2.32", "types-tqdm~=4.66", @@ -45,6 +45,13 @@ venv = ".venv" [tool.pytest.ini_options] testpaths = ["tests"] +[tool.ruff] +extend-exclude = ["fimfarchive/__init__.py"] + +[tool.ruff.lint] +select = ["A", "E", "F", "N", "RUF", "T10", "W"] +ignore = ["N801", "RUF012"] + [build-system] requires = ["hatchling"] build-backend = "hatchling.build" diff --git a/tests/fetchers/test_directory.py b/tests/fetchers/test_directory.py index d886f78..1470089 100644 --- a/tests/fetchers/test_directory.py +++ b/tests/fetchers/test_directory.py @@ -156,7 +156,7 @@ class TestDirectoryFetcher: """ assert 3 == len(fetcher) - def test_len_caching(test, fetcher): + def test_len_caching(self, fetcher): """ Tests len is only calculated once. """