Commit d6924fa7 authored by mathieui's avatar mathieui

fix: please python 3.7

parent 20e4c2c2
...@@ -137,7 +137,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -137,7 +137,7 @@ class XMLStream(asyncio.BaseProtocol):
force_starttls: Optional[bool] force_starttls: Optional[bool]
disable_starttls: Optional[bool] disable_starttls: Optional[bool]
waiting_queue: asyncio.Queue[Tuple[Union[StanzaBase, str], bool]] waiting_queue: asyncio.Queue
# A dict of {name: handle} # A dict of {name: handle}
scheduled_events: Dict[str, TimerHandle] scheduled_events: Dict[str, TimerHandle]
...@@ -243,7 +243,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -243,7 +243,7 @@ class XMLStream(asyncio.BaseProtocol):
__filters: _FiltersDict __filters: _FiltersDict
# Current connection attempt (Future) # Current connection attempt (Future)
_current_connection_attempt: Optional[Future[None]] _current_connection_attempt: Optional[Future]
#: A list of DNS results that have not yet been tried. #: A list of DNS results that have not yet been tried.
_dns_answers: Optional[Iterator[Tuple[str, str, int]]] _dns_answers: Optional[Iterator[Tuple[str, str, int]]]
...@@ -257,7 +257,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -257,7 +257,7 @@ class XMLStream(asyncio.BaseProtocol):
disconnect_reason: Optional[str] disconnect_reason: Optional[str]
#: An asyncio Future being done when the stream is disconnected. #: An asyncio Future being done when the stream is disconnected.
disconnected: Future[bool] disconnected: Future
# If the session has been started or not # If the session has been started or not
_session_started: bool _session_started: bool
...@@ -504,7 +504,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -504,7 +504,7 @@ class XMLStream(asyncio.BaseProtocol):
else: else:
self.loop.run_until_complete(self.disconnected) self.loop.run_until_complete(self.disconnected)
else: else:
tasks: List[Future[bool]] = [asyncio.sleep(timeout, loop=self.loop)] tasks: List[Future] = [asyncio.sleep(timeout, loop=self.loop)]
if not forever: if not forever:
tasks.append(self.disconnected) tasks.append(self.disconnected)
self.loop.run_until_complete(asyncio.wait(tasks, loop=self.loop)) self.loop.run_until_complete(asyncio.wait(tasks, loop=self.loop))
...@@ -626,7 +626,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -626,7 +626,7 @@ class XMLStream(asyncio.BaseProtocol):
self._current_connection_attempt.cancel() self._current_connection_attempt.cancel()
self._current_connection_attempt = None self._current_connection_attempt = None
def disconnect(self, wait: Union[float, int] = 2.0, reason: Optional[str] = None, ignore_send_queue: bool = False) -> Future[None]: def disconnect(self, wait: Union[float, int] = 2.0, reason: Optional[str] = None, ignore_send_queue: bool = False) -> Future:
"""Close the XML stream and wait for an acknowldgement from the server for """Close the XML stream and wait for an acknowldgement from the server for
at most `wait` seconds. After the given number of seconds has at most `wait` seconds. After the given number of seconds has
passed without a response from the server, or when the server passed without a response from the server, or when the server
...@@ -665,7 +665,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -665,7 +665,7 @@ class XMLStream(asyncio.BaseProtocol):
else: else:
self._set_disconnected_future() self._set_disconnected_future()
self.event("disconnected", reason) self.event("disconnected", reason)
future: Future[None] = Future() future: Future = Future()
future.set_result(None) future.set_result(None)
return future return future
...@@ -1165,7 +1165,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -1165,7 +1165,7 @@ class XMLStream(asyncio.BaseProtocol):
async def _continue_slow_send( async def _continue_slow_send(
self, self,
task: asyncio.Task[Optional[StanzaBase]], task: asyncio.Task,
already_used: Set[Filter] already_used: Set[Filter]
) -> None: ) -> None:
""" """
...@@ -1395,7 +1395,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -1395,7 +1395,7 @@ class XMLStream(asyncio.BaseProtocol):
:param int timeout: Timeout :param int timeout: Timeout
:raises: :class:`asyncio.TimeoutError` when the timeout is reached :raises: :class:`asyncio.TimeoutError` when the timeout is reached
""" """
fut: Future[Any] = asyncio.Future() fut: Future = asyncio.Future()
def result_handler(event_data: Any) -> None: def result_handler(event_data: Any) -> None:
if not fut.done(): if not fut.done():
...@@ -1426,7 +1426,7 @@ class XMLStream(asyncio.BaseProtocol): ...@@ -1426,7 +1426,7 @@ class XMLStream(asyncio.BaseProtocol):
finally: finally:
self.del_event_handler(event, handler) self.del_event_handler(event, handler)
def wrap(self, coroutine: Coroutine[None, None, T]) -> Future[T]: def wrap(self, coroutine: Coroutine[None, None, T]) -> Future:
"""Make a Future out of a coroutine with the current loop. """Make a Future out of a coroutine with the current loop.
:param coroutine: The coroutine to wrap. :param coroutine: The coroutine to wrap.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment