diff --git a/client/src/telethon/_impl/mtsender/reconnection.py b/client/src/telethon/_impl/mtsender/reconnection.py index 20e38777..19054f6b 100644 --- a/client/src/telethon/_impl/mtsender/reconnection.py +++ b/client/src/telethon/_impl/mtsender/reconnection.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod +from typing import Optional class ReconnectionPolicy(ABC): @@ -10,14 +11,14 @@ class ReconnectionPolicy(ABC): """ @abstractmethod - def should_retry(self, attempts: int) -> float | None: + def should_retry(self, attempts: int) -> Optional[float]: """ Determines whether the client should retry the connection attempt. """ class NoReconnect(ReconnectionPolicy): - def should_retry(self, attempts: int) -> float | None: + def should_retry(self, attempts: int) -> Optional[float]: return None @@ -28,7 +29,7 @@ class FixedReconnect(ReconnectionPolicy): self.max_attempts = attempts self.delay = delay - def should_retry(self, attempts: int) -> float | None: + def should_retry(self, attempts: int) -> Optional[float]: if attempts < self.max_attempts: return self.delay diff --git a/client/src/telethon/_impl/mtsender/sender.py b/client/src/telethon/_impl/mtsender/sender.py index db60b3ce..37ab838c 100644 --- a/client/src/telethon/_impl/mtsender/sender.py +++ b/client/src/telethon/_impl/mtsender/sender.py @@ -166,7 +166,7 @@ class Sender: addr: str mtp: Mtp _connector: Connector - _reconnection_policy: ReconnectionPolicy | None + _reconnection_policy: Optional[ReconnectionPolicy] _logger: logging.Logger _reader: AsyncReader _writer: AsyncWriter @@ -190,7 +190,7 @@ class Sender: addr: str, *, connector: Connector, - reconnection_policy: ReconnectionPolicy | None = None, + reconnection_policy: Optional[ReconnectionPolicy] = None, base_logger: logging.Logger, ) -> Self: ip, port = addr.split(":") @@ -570,7 +570,7 @@ async def connect( auth_key: Optional[bytes], base_logger: logging.Logger, connector: Connector, - reconnection_policy: ReconnectionPolicy | None = None, + reconnection_policy: Optional[ReconnectionPolicy] = None, ) -> Sender: if auth_key is None: sender = await Sender.connect(