diff --git a/client/src/telethon/_impl/mtsender/sender.py b/client/src/telethon/_impl/mtsender/sender.py index fd9f31a2..eb9facd3 100644 --- a/client/src/telethon/_impl/mtsender/sender.py +++ b/client/src/telethon/_impl/mtsender/sender.py @@ -287,7 +287,7 @@ class Sender: return self._mtp.auth_key -async def connect(transport, addr): +async def connect(transport: Transport, addr: str) -> Tuple[Sender, Enqueuer]: sender, enqueuer = await Sender.connect(transport, Plain(), addr) return await generate_auth_key(sender, enqueuer) diff --git a/client/tests/mtproto_test.py b/client/tests/mtproto_test.py index 4cdfc1c4..4c256878 100644 --- a/client/tests/mtproto_test.py +++ b/client/tests/mtproto_test.py @@ -1,6 +1,7 @@ import struct from pytest import raises +from telethon._impl.crypto.auth_key import AuthKey from telethon._impl.mtproto.mtp import Encrypted, Plain, RpcError from telethon._impl.tl.mtproto.types import RpcError as GeneratedRpcError @@ -70,8 +71,8 @@ REQUEST = b"Hey!" REQUEST_B = b"Bye!" -def auth_key() -> bytes: - return bytes(256) +def auth_key() -> AuthKey: + return AuthKey.from_bytes(bytes(256)) def ensure_buffer_is_message(buffer: bytes, body: bytes, seq_no: int) -> None: diff --git a/client/tests/mtsender_test.py b/client/tests/mtsender_test.py index 031c5f85..b187fb7f 100644 --- a/client/tests/mtsender_test.py +++ b/client/tests/mtsender_test.py @@ -1,6 +1,7 @@ import asyncio import logging +from pytest import LogCaptureFixture from telethon._impl.mtproto.transport.full import Full from telethon._impl.mtsender.sender import connect @@ -11,13 +12,13 @@ TELEGRAM_DEFAULT_TEST_DC = TELEGRAM_TEST_DC_2 TEST_TIMEOUT = 10000 -def test_invoke_encrypted_method(caplog) -> None: +def test_invoke_encrypted_method(caplog: LogCaptureFixture) -> None: caplog.set_level(logging.DEBUG) - async def func(): + async def func() -> None: deadline = asyncio.get_running_loop().time() + TEST_TIMEOUT - def timeout(): + def timeout() -> float: return deadline - asyncio.get_running_loop().time() sender, enqueuer = await asyncio.wait_for( diff --git a/client/tests/transport/abridged_test.py b/client/tests/transport/abridged_test.py index 71af5dc1..91a85e10 100644 --- a/client/tests/transport/abridged_test.py +++ b/client/tests/transport/abridged_test.py @@ -11,7 +11,7 @@ class Output(bytearray): self += data -def setup_pack(n: int) -> Tuple[Abridged, bytes, bytearray]: +def setup_pack(n: int) -> Tuple[Abridged, bytes, Output]: input = bytes(x & 0xFF for x in range(n)) return Abridged(), input, Output() diff --git a/client/tests/transport/full_test.py b/client/tests/transport/full_test.py index b85827fc..a961b7ef 100644 --- a/client/tests/transport/full_test.py +++ b/client/tests/transport/full_test.py @@ -11,7 +11,7 @@ class Output(bytearray): self += data -def setup_pack(n: int) -> Tuple[Full, bytes, bytearray]: +def setup_pack(n: int) -> Tuple[Full, bytes, Output]: input = bytes(x & 0xFF for x in range(n)) return Full(), input, Output() diff --git a/client/tests/transport/intermediate_test.py b/client/tests/transport/intermediate_test.py index b3a6efe8..d35df085 100644 --- a/client/tests/transport/intermediate_test.py +++ b/client/tests/transport/intermediate_test.py @@ -11,7 +11,7 @@ class Output(bytearray): self += data -def setup_pack(n: int) -> Tuple[Intermediate, bytes, bytearray]: +def setup_pack(n: int) -> Tuple[Intermediate, bytes, Output]: input = bytes(x & 0xFF for x in range(n)) return Intermediate(), input, Output()