mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Fix the rest of the typing hints (#232)
* ignore kad * fix swarm, and minor * fix init and swarm * ignore pb * enable mypy * fix basic host * fix tcp * fix mplex * add typing for pb * skip format pyi * [mypy] no need to ignore pb now * add typing to chat
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from libp2p.stream_muxer.abc import IMuxedConn, IMuxedStream
|
||||
from libp2p.typing import TProtocol
|
||||
|
||||
from .net_stream_interface import INetStream
|
||||
|
||||
@ -7,20 +8,20 @@ class NetStream(INetStream):
|
||||
|
||||
muxed_stream: IMuxedStream
|
||||
mplex_conn: IMuxedConn
|
||||
protocol_id: str
|
||||
protocol_id: TProtocol
|
||||
|
||||
def __init__(self, muxed_stream: IMuxedStream) -> None:
|
||||
self.muxed_stream = muxed_stream
|
||||
self.mplex_conn = muxed_stream.mplex_conn
|
||||
self.protocol_id = None
|
||||
|
||||
def get_protocol(self) -> str:
|
||||
def get_protocol(self) -> TProtocol:
|
||||
"""
|
||||
:return: protocol id that stream runs on
|
||||
"""
|
||||
return self.protocol_id
|
||||
|
||||
def set_protocol(self, protocol_id: str) -> None:
|
||||
def set_protocol(self, protocol_id: TProtocol) -> None:
|
||||
"""
|
||||
:param protocol_id: protocol id that stream runs on
|
||||
:return: true if successful
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from libp2p.stream_muxer.abc import IMuxedConn
|
||||
from libp2p.typing import TProtocol
|
||||
|
||||
|
||||
class INetStream(ABC):
|
||||
@ -8,13 +9,13 @@ class INetStream(ABC):
|
||||
mplex_conn: IMuxedConn
|
||||
|
||||
@abstractmethod
|
||||
def get_protocol(self) -> str:
|
||||
def get_protocol(self) -> TProtocol:
|
||||
"""
|
||||
:return: protocol id that stream runs on
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def set_protocol(self, protocol_id: str) -> bool:
|
||||
def set_protocol(self, protocol_id: TProtocol) -> bool:
|
||||
"""
|
||||
:param protocol_id: protocol id that stream runs on
|
||||
:return: true if successful
|
||||
|
||||
Reference in New Issue
Block a user