diff --git a/v6d3music/app.py b/v6d3music/app.py index e13a6be..c87b7b0 100644 --- a/v6d3music/app.py +++ b/v6d3music/app.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import asyncio import aiohttp @@ -54,7 +56,7 @@ class AppContext: task = asyncio.create_task(start_app(app)) return app, task - async def __aenter__(self) -> "AppContext": + async def __aenter__(self) -> AppContext: self.__task: asyncio.Task[tuple[web.Application, asyncio.Task[None]] | None] = asyncio.create_task(self.start()) return self diff --git a/v6d3music/core/mainservice.py b/v6d3music/core/mainservice.py index 98c078e..975178a 100644 --- a/v6d3music/core/mainservice.py +++ b/v6d3music/core/mainservice.py @@ -1,7 +1,9 @@ +from __future__ import annotations + import asyncio import traceback from contextlib import AsyncExitStack -from typing import AsyncIterable, Callable, TypeVar +from typing import AsyncIterable, TypeVar import discord @@ -106,7 +108,7 @@ class MainService: async def create(self, guild: discord.Guild) -> MainAudio: return await MainAudio.create(self.__servicing, self.__volumes, self.__queues, guild) - async def __aenter__(self) -> "MainService": + async def __aenter__(self) -> MainService: async with AsyncExitStack() as es: self.__locks = Locks() self.__volumes = await es.enter_async_context(DbFactory(myroot / "volume.db", kvfactory=KVJson())) @@ -120,6 +122,7 @@ class MainService: self.register_instrumentation() self.__es = es.pop_all() return self + raise RuntimeError async def __aexit__(self, exc_type, exc_val, exc_tb): async with self.__es: