mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Add type hints to peer folder
This commit is contained in:
@ -1,46 +1,53 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
Sequence,
|
||||
)
|
||||
|
||||
from multiaddr import Multiaddr
|
||||
|
||||
|
||||
class IPeerData(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def get_protocols(self):
|
||||
def get_protocols(self) -> List[str]:
|
||||
"""
|
||||
:return: all protocols associated with given peer
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def add_protocols(self, protocols):
|
||||
def add_protocols(self, protocols: Sequence[str]) -> None:
|
||||
"""
|
||||
:param protocols: protocols to add
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def set_protocols(self, protocols):
|
||||
def set_protocols(self, protocols: Sequence[str]) -> None:
|
||||
"""
|
||||
:param protocols: protocols to add
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def add_addrs(self, addrs):
|
||||
def add_addrs(self, addrs: Sequence[Multiaddr]) -> None:
|
||||
"""
|
||||
:param addrs: multiaddresses to add
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_addrs(self):
|
||||
def get_addrs(self) -> List[Multiaddr]:
|
||||
"""
|
||||
:return: all multiaddresses
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def clear_addrs(self):
|
||||
def clear_addrs(self) -> None:
|
||||
"""
|
||||
Clear all addresses
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def put_metadata(self, key, val):
|
||||
def put_metadata(self, key: Any, val: Any) -> None:
|
||||
"""
|
||||
:param key: key in KV pair
|
||||
:param val: val to associate with key
|
||||
@ -48,7 +55,7 @@ class IPeerData(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_metadata(self, key):
|
||||
def get_metadata(self, key: Any) -> Any:
|
||||
"""
|
||||
:param key: key in KV pair
|
||||
:return: val for key
|
||||
|
||||
Reference in New Issue
Block a user