Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AsyncContextManager as Parent Class to BaseUpdateProcessor #4001

Merged
merged 2 commits into from Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions telegram/ext/_baseupdateprocessor.py
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