diff --git a/src/lootscraper/database.py b/src/lootscraper/database.py index 9572181..7915a50 100644 --- a/src/lootscraper/database.py +++ b/src/lootscraper/database.py @@ -3,7 +3,7 @@ import logging from datetime import datetime, timedelta, timezone from pathlib import Path -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, Self import sqlalchemy as sa from alembic import command @@ -282,7 +282,7 @@ def __init__(self: LootDatabase, echo: bool = False) -> None: self.Session = scoped_session(session_factory) # TODO: Can this be changed with SQLAlchemy 2.0 and the removal of threaded execution? - def __enter__(self: LootDatabase) -> LootDatabase: + def __enter__(self: LootDatabase) -> Self: return self def __exit__( diff --git a/src/lootscraper/telegrambot.py b/src/lootscraper/telegrambot.py index c3ab1e9..92426d8 100644 --- a/src/lootscraper/telegrambot.py +++ b/src/lootscraper/telegrambot.py @@ -6,7 +6,7 @@ import traceback from datetime import datetime, timedelta, timezone from http.client import RemoteDisconnected -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Self import humanize import sqlalchemy as sa @@ -101,7 +101,7 @@ def __init__( self.Session = scoped_session self.application: Application | None = None # type: ignore - async def __aenter__(self: TelegramBot) -> TelegramBot: + async def __aenter__(self: TelegramBot) -> Self: try: await self.start() except TelegramError: