mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-18 15:20:42 +01:00
Add AsyncContextManager
as Parent Class to BaseUpdateProcessor
(#4001)
This commit is contained in:
parent
fd6a0fe899
commit
cc45f49a4f
1 changed files with 5 additions and 3 deletions
|
@ -20,10 +20,12 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from asyncio import BoundedSemaphore
|
||||
from types import TracebackType
|
||||
from typing import Any, Awaitable, Optional, Type, final
|
||||
from typing import Any, AsyncContextManager, Awaitable, Optional, Type, TypeVar, final
|
||||
|
||||
_BUPT = TypeVar("_BUPT", bound="BaseUpdateProcessor")
|
||||
|
||||
|
||||
class BaseUpdateProcessor(ABC):
|
||||
class BaseUpdateProcessor(AsyncContextManager["BaseUpdateProcessor"], ABC):
|
||||
"""An abstract base class for update processors. You can use this class to implement
|
||||
your own update processor.
|
||||
|
||||
|
@ -67,7 +69,7 @@ class BaseUpdateProcessor(ABC):
|
|||
raise ValueError("`max_concurrent_updates` must be a positive integer!")
|
||||
self._semaphore = BoundedSemaphore(self.max_concurrent_updates)
|
||||
|
||||
async def __aenter__(self) -> "BaseUpdateProcessor":
|
||||
async def __aenter__(self: _BUPT) -> _BUPT: # noqa: PYI019
|
||||
"""|async_context_manager| :meth:`initializes <initialize>` the Processor.
|
||||
|
||||
Returns:
|
||||
|
|
Loading…
Reference in a new issue