Skip to content

Commit

Permalink
Add AsyncContextManager as Parent Class to BaseUpdateProcessor (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibo-Joshi committed Dec 13, 2023
1 parent fd6a0fe commit cc45f49
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions telegram/ext/_baseupdateprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -67,7 +69,7 @@ def __init__(self, max_concurrent_updates: int):
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:
Expand Down

0 comments on commit cc45f49

Please sign in to comment.