From edf3e06bd01c41bdf0053454ae321e259e31824b Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 19 Oct 2024 23:04:15 +0200 Subject: [PATCH] Fix errors reported by tools/check --- client/doc/modules/types.rst | 10 ++++++++++ client/src/telethon/_impl/client/client/client.py | 6 +++--- client/src/telethon/_impl/client/types/__init__.py | 12 ++++++++++-- client/src/telethon/_impl/crypto/aes.py | 2 +- client/src/telethon/_impl/tl/core/reader.py | 3 ++- client/src/telethon/types/__init__.py | 4 ++++ tools/copy_client_signatures.py | 7 ++++++- 7 files changed, 36 insertions(+), 8 deletions(-) diff --git a/client/doc/modules/types.rst b/client/doc/modules/types.rst index c18ba386..b665ce36 100644 --- a/client/doc/modules/types.rst +++ b/client/doc/modules/types.rst @@ -102,6 +102,16 @@ Private definitions Generic parameter used by :class:`AsyncList`. +.. currentmodule:: telethon._impl.client.types.keyboard + +.. class:: AnyButton + + Generic parameter used by :class:`Keyboard`. + +.. class:: AnyInlineButton + + Generic parameter used by :class:`InlineKeyboard`. + .. currentmodule:: telethon._impl.client.events.filters.combinators .. autoclass:: Combinable diff --git a/client/src/telethon/_impl/client/client/client.py b/client/src/telethon/_impl/client/client/client.py index 1c199d25..2d434022 100644 --- a/client/src/telethon/_impl/client/client/client.py +++ b/client/src/telethon/_impl/client/client/client.py @@ -253,9 +253,9 @@ class Client: self._message_box = MessageBox(base_logger=base_logger) self._chat_hashes = ChatHashCache(None) self._last_update_limit_warn: Optional[float] = None - self._updates: asyncio.Queue[tuple[abcs.Update, dict[int, Peer]]] = ( - asyncio.Queue(maxsize=self._config.update_queue_limit or 0) - ) + self._updates: asyncio.Queue[ + tuple[abcs.Update, dict[int, Peer]] + ] = asyncio.Queue(maxsize=self._config.update_queue_limit or 0) self._dispatcher: Optional[asyncio.Task[None]] = None self._handlers: dict[ Type[Event], diff --git a/client/src/telethon/_impl/client/types/__init__.py b/client/src/telethon/_impl/client/types/__init__.py index df726a69..906616f7 100644 --- a/client/src/telethon/_impl/client/types/__init__.py +++ b/client/src/telethon/_impl/client/types/__init__.py @@ -14,7 +14,13 @@ from .file import ( try_get_url_path, ) from .inline_result import InlineResult -from .keyboard import InlineKeyboard, Keyboard, KeyboardType +from .keyboard import ( + ForcedReplyKeyboard, + HiddenKeyboard, + InlineKeyboard, + Keyboard, + KeyboardType, +) from .login_token import LoginToken from .message import ( Message, @@ -61,7 +67,9 @@ __all__ = [ "Participant", "PasswordToken", "RecentAction", - "Keyboard", + "ForcedReplyKeyboard", + "HiddenKeyboard", "InlineKeyboard", + "Keyboard", "KeyboardType", ] diff --git a/client/src/telethon/_impl/crypto/aes.py b/client/src/telethon/_impl/crypto/aes.py index 1eace6f9..d8957206 100644 --- a/client/src/telethon/_impl/crypto/aes.py +++ b/client/src/telethon/_impl/crypto/aes.py @@ -18,7 +18,7 @@ try: ) except ImportError: - import pyaes # type: ignore [import-untyped] + import pyaes def ige_encrypt( plaintext: bytes | bytearray | memoryview, key: bytes, iv: bytes diff --git a/client/src/telethon/_impl/tl/core/reader.py b/client/src/telethon/_impl/tl/core/reader.py index c9103317..0ca45385 100644 --- a/client/src/telethon/_impl/tl/core/reader.py +++ b/client/src/telethon/_impl/tl/core/reader.py @@ -9,7 +9,8 @@ if TYPE_CHECKING: from .serializable import Serializable class Buffer(Protocol): - def __buffer__(self, flags: int, /) -> memoryview: ... + def __buffer__(self, flags: int, /) -> memoryview: + ... AnySerializable = TypeVar("AnySerializable", bound="Serializable") diff --git a/client/src/telethon/types/__init__.py b/client/src/telethon/types/__init__.py index 0a47300d..5cf1e900 100644 --- a/client/src/telethon/types/__init__.py +++ b/client/src/telethon/types/__init__.py @@ -12,7 +12,9 @@ from .._impl.client.types import ( Dialog, Draft, File, + ForcedReplyKeyboard, Group, + HiddenKeyboard, InlineKeyboard, InlineResult, Keyboard, @@ -38,7 +40,9 @@ __all__ = [ "Dialog", "Draft", "File", + "ForcedReplyKeyboard", "Group", + "HiddenKeyboard", "InlineKeyboard", "InlineResult", "Keyboard", diff --git a/tools/copy_client_signatures.py b/tools/copy_client_signatures.py index 219de610..011af1d4 100644 --- a/tools/copy_client_signatures.py +++ b/tools/copy_client_signatures.py @@ -123,7 +123,12 @@ def main() -> None: generated = ast.unparse( ast.ClassDef( - name="Client", bases=[], keywords=[], body=class_body, decorator_list=[] + name="Client", + bases=[], + keywords=[], + body=class_body, + decorator_list=[], + type_params=[], ) )[len("class Client:") :].strip()