From 717f1b7dd3d31a271c8d901c9a206da8def993b4 Mon Sep 17 00:00:00 2001 From: Nikita Babaev Date: Wed, 4 Dec 2024 17:56:11 +0400 Subject: [PATCH] Small edits for linter --- pyproject.toml | 29 +++++++++++++++++++++++++++++ src/account/schemas.py | 2 +- src/auth/views.py | 4 ++-- src/utils/add_words_to_db.py | 2 +- src/utils/database.py | 3 ++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d509f5f..1f12211 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,15 +32,44 @@ ruff = "0.5.6" [tool.ruff] line-length = 80 +exclude = [ + "**/migrations/*", + "**/tests/*", + "**/__init__.py", + "**/__pycache__", + "**/conftest.py", +] + [tool.ruff.lint] select = [ "ALL", ] ignore = [ + "D", "Q000", # single quotes + "RUF001", + "RUF002", + "RUF003", + "CPY", + "FBT001", + "FBT002", + "FA100", + "FA102", + "FURB118", + "DTZ", + "FAST001", + "DOC", + "ANN003", + "PTH", + "B904", + "TRY300", + "TRY301", ] +[tool.ruff.lint.per-file-ignores] +"crud.py" = ["E501"] + [tool.ruff.format] quote-style = "single" diff --git a/src/account/schemas.py b/src/account/schemas.py index 5b00ea6..8d5f7c4 100644 --- a/src/account/schemas.py +++ b/src/account/schemas.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional +from typing import List, Optional from uuid import UUID from pydantic import BaseModel diff --git a/src/auth/views.py b/src/auth/views.py index 77629c8..fe6a387 100644 --- a/src/auth/views.py +++ b/src/auth/views.py @@ -114,7 +114,7 @@ async def refresh_access_token( }, include_in_schema=False, ) -async def check_tokens( # noqa: RUF029 +async def check_tokens( request: Request, response: Response, token_payload: Annotated[ @@ -132,7 +132,7 @@ async def check_tokens( # noqa: RUF029 **API_RESPONSES['logout'], }, ) -async def logout( # noqa: RUF029 +async def logout( response: Response, token_payload: Annotated[ Dict[str, Any], diff --git a/src/utils/add_words_to_db.py b/src/utils/add_words_to_db.py index 097afff..43c108e 100644 --- a/src/utils/add_words_to_db.py +++ b/src/utils/add_words_to_db.py @@ -14,7 +14,7 @@ async def load_words_from_file(file_path: str) -> None: password=settings.DATABASE_PASSWORD, ) - with open(file_path, 'r') as file: + with open(file_path) as file: # noqa: ASYNC230 words = [line.strip() for line in file if line.strip()] async with pool.acquire() as connection, connection.transaction(): diff --git a/src/utils/database.py b/src/utils/database.py index 7dfc267..c2f7bd9 100644 --- a/src/utils/database.py +++ b/src/utils/database.py @@ -1,5 +1,6 @@ import json from contextlib import asynccontextmanager +from typing import Any, AsyncGenerator from asyncpg import Pool, create_pool from asyncpg.connection import Connection @@ -23,7 +24,7 @@ def pool(self) -> Pool: return self.__pool @asynccontextmanager - async def lifespan(self): + async def lifespan(self) -> AsyncGenerator[None, Any, None]: """ Контекстный менеджер для управления временем жизни пула соединений. Использовать только для инициализации и завершения работы приложения.