Skip to content

Commit

Permalink
chore: ruff formating and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Nov 21, 2024
1 parent 95bf6fc commit 09ff6f9
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 43 deletions.
8 changes: 4 additions & 4 deletions alembic/versions/_2023_12_15_18_47_init_alembic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"""

from typing import Sequence, Union
from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "5434c5fc5066"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = None
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"""

from typing import Sequence, Union
from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "e4798976bd79"
down_revision: Union[str, None] = "5434c5fc5066"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = "5434c5fc5066"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
8 changes: 4 additions & 4 deletions alembic/versions/_2024_03_24_18_20_migrate_to_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

from typing import Sequence, Union
from collections.abc import Sequence

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
Expand All @@ -15,9 +15,9 @@

# revision identifiers, used by Alembic.
revision: str = "ae811bbde3f1"
down_revision: Union[str, None] = "e4798976bd79"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = "e4798976bd79"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"""

from typing import Sequence, Union
from collections.abc import Sequence

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "440853283436"
down_revision: Union[str, None] = "ae811bbde3f1"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = "ae811bbde3f1"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
8 changes: 4 additions & 4 deletions alembic/versions/_2024_09_28_19_46_make_telegram_id_bigint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"""

from typing import Sequence, Union
from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "470fe3126fc0"
down_revision: Union[str, None] = "440853283436"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
down_revision: str | None = "440853283436"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/api/logging_.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import inspect
import logging.config
import os
from typing import Any, Dict
from typing import Any

import fastapi
import yaml
Expand All @@ -26,7 +26,7 @@ def filter(self, record: logging.LogRecord) -> bool:
logger.addFilter(RelativePathFilter())


async def run_endpoint_function(*, dependant: Dependant, values: Dict[str, Any], is_coroutine: bool) -> Any:
async def run_endpoint_function(*, dependant: Dependant, values: dict[str, Any], is_coroutine: bool) -> Any:
# Only called by get_request_handler. Has been split into its own function to
# facilitate profiling endpoints, since inner functions are harder to profile.
assert dependant.call is not None, "dependant.call must be a function"
Expand Down
6 changes: 3 additions & 3 deletions src/bot/i18n.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Any, Dict, List, Protocol
from typing import Any, Protocol

from aiogram_dialog.api.protocols import DialogManager
from aiogram_dialog.widgets.common import WhenCondition
Expand All @@ -20,7 +20,7 @@ def __init__(self, text: str, when: WhenCondition = None):
super().__init__(when)
self.text = text

async def _render_text(self, data: Dict, manager: DialogManager) -> str:
async def _render_text(self, data: dict, manager: DialogManager) -> str:
format_text = manager.middleware_data.get(
DIALOG_I18N_FORMAT_KEY,
default_format_text,
Expand All @@ -32,7 +32,7 @@ def default_format_text(text: str, data: Values) -> str:
return text.format_map(data)


def make_i18n_middleware(locales: List[str], default_locale: str = "en"):
def make_i18n_middleware(locales: list[str], default_locale: str = "en"):
loader = FluentResourceLoader(
os.path.join(
os.getcwd(),
Expand Down
12 changes: 6 additions & 6 deletions src/bot/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import os
from collections.abc import Awaitable, Callable, Set
from typing import Any, Dict, Optional, Union
from typing import Any

from aiogram import BaseMiddleware, Router
from aiogram.dispatcher.event.handler import HandlerObject
Expand Down Expand Up @@ -87,7 +87,7 @@ def _create_log_record(
class DialogI18nMiddleware(BaseMiddleware):
def __init__(
self,
l10ns: Dict[str, FluentLocalization],
l10ns: dict[str, FluentLocalization],
default_lang: str,
):
super().__init__()
Expand All @@ -97,11 +97,11 @@ def __init__(
async def __call__(
self,
handler: Callable[
[Union[Message, CallbackQuery], Dict[str, Any]],
[Message | CallbackQuery, dict[str, Any]],
Awaitable[Any],
],
event: Union[Message, CallbackQuery],
data: Dict[str, Any],
event: Message | CallbackQuery,
data: dict[str, Any],
) -> Any:
lang = self.default_lang
if hasattr(event, "from_user") and event.from_user:
Expand All @@ -115,7 +115,7 @@ async def __call__(
def setup(
self: BaseMiddleware,
router: Router,
exclude: Optional[Set[str]] = None,
exclude: Set[str] | None = None,
) -> BaseMiddleware:
"""
Register middleware for all events in the Router
Expand Down
2 changes: 1 addition & 1 deletion src/bot/routers/booking/widgets/time_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async def _process_item_callback(
else:
endpoint_timepoints.append(clicked_timepoint)
for i in range(len(endpoint_timepoints)):
if isinstance(endpoint_timepoints[i], (datetime.time,)):
if isinstance(endpoint_timepoints[i], datetime.time):
endpoint_timepoints[i] = endpoint_timepoints[i].isoformat()
self.set_widget_data(manager, endpoint_timepoints)
return True
Expand Down
6 changes: 3 additions & 3 deletions src/dependendies/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__all__ = ["VerifiedDep", "VerifiedDepWithUserID", "verify_request"]

from typing import Annotated, TypeAlias, cast
from typing import Annotated, cast

from fastapi import Depends
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
Expand Down Expand Up @@ -72,5 +72,5 @@ def verify_request_with_user_id(
return cast(VerificationResultWithUserId, verification)


VerifiedDep: TypeAlias = Annotated[SucceedVerificationResult, Depends(verify_request)]
VerifiedDepWithUserID: TypeAlias = Annotated[VerificationResultWithUserId, Depends(verify_request_with_user_id)]
VerifiedDep = Annotated[SucceedVerificationResult, Depends(verify_request)]
VerifiedDepWithUserID = Annotated[VerificationResultWithUserId, Depends(verify_request_with_user_id)]
3 changes: 1 addition & 2 deletions src/storage/sql/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
from sqlalchemy.orm import DeclarativeBase


class Base(DeclarativeBase):
...
class Base(DeclarativeBase): ...
9 changes: 3 additions & 6 deletions src/storage/sql/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@

class AbstractSQLAlchemyStorage(ABC):
@abstractmethod
def create_session(self) -> AsyncSession:
...
def create_session(self) -> AsyncSession: ...

@abstractmethod
async def create_all(self) -> None:
...
async def create_all(self) -> None: ...

@abstractmethod
async def close_connection(self):
...
async def close_connection(self): ...


class SQLAlchemyStorage(AbstractSQLAlchemyStorage):
Expand Down

0 comments on commit 09ff6f9

Please sign in to comment.