Fix on type hints

This commit is contained in:
NIC619
2019-07-28 14:30:15 +08:00
parent edd164c878
commit d716e90e17
11 changed files with 34 additions and 28 deletions

View File

@ -35,7 +35,7 @@ class INetwork(ABC):
"""
@abstractmethod
def set_stream_handler(self, protocol_id: str, stream_handler: Callable[[NetStream], None]) -> bool:
def set_stream_handler(self, protocol_id: str, stream_handler: Callable[[NetStream], Coroutine[Any, Any, None]]) -> bool:
"""
:param protocol_id: protocol id used on stream
:param stream_handler: a stream handler instance

View File

@ -4,9 +4,13 @@ from typing import (
Coroutine,
)
from libp2p.stream_muxer.mplex.mplex import Mplex
class INetStream(ABC):
mplex_conn: Mplex
@abstractmethod
def get_protocol(self) -> str:
"""

View File

@ -74,7 +74,7 @@ class Swarm(INetwork):
def get_peer_id(self) -> ID:
return self.self_id
def set_stream_handler(self, protocol_id: str, stream_handler: Callable[[NetStream], None]) -> bool:
def set_stream_handler(self, protocol_id: str, stream_handler: Callable[[NetStream], Coroutine[Any, Any, None]]) -> bool:
"""
:param protocol_id: protocol id used on stream
:param stream_handler: a stream handler instance