Migrate from Black to Ruff (#1750)

* Migrate from Black to Ruff and reformat code with enabling additional linter checks

* Add changelog for migration to Ruff as formatter and linter

* Add type ignores for specific attributes and replace tuple with set for chat type check

* Remove file from another changes
This commit is contained in:
Alex Root Junior 2026-01-04 21:34:08 +02:00 committed by GitHub
parent a4a3f42c71
commit ec7da0f678
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
214 changed files with 886 additions and 964 deletions

View file

@ -1,12 +1,8 @@
import asyncio
from collections.abc import AsyncGenerator, AsyncIterable
from typing import (
Any,
AsyncContextManager,
AsyncGenerator,
AsyncIterable,
Dict,
List,
Union,
)
from unittest.mock import AsyncMock, patch
@ -115,10 +111,10 @@ class TestAiohttpSession:
str_: str
int_: int
bool_: bool
unset_: Union[str, Default] = Default("parse_mode")
unset_: str | Default = Default("parse_mode")
null_: None
list_: List[str]
dict_: Dict[str, Any]
list_: list[str]
dict_: dict[str, Any]
session = AiohttpSession()
form = session.build_form_data(

View file

@ -1,6 +1,7 @@
import datetime
import json
from typing import Any, AsyncContextManager, AsyncGenerator, Dict, Optional
from collections.abc import AsyncGenerator
from typing import Any, AsyncContextManager
from unittest.mock import AsyncMock, patch
import pytest
@ -39,7 +40,7 @@ class CustomSession(BaseSession):
self,
token: str,
method: TelegramMethod[TelegramType],
timeout: Optional[int] = UNSET_PARSE_MODE,
timeout: int | None = UNSET_PARSE_MODE,
) -> None: # type: ignore
assert isinstance(token, str)
assert isinstance(method, TelegramMethod)
@ -47,7 +48,7 @@ class CustomSession(BaseSession):
async def stream_content(
self,
url: str,
headers: Optional[Dict[str, Any]] = None,
headers: dict[str, Any] | None = None,
timeout: int = 30,
chunk_size: int = 65536,
raise_for_status: bool = True,