mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Run black over repo
This commit is contained in:
@ -1,8 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import (
|
||||
List,
|
||||
Sequence,
|
||||
)
|
||||
from typing import List, Sequence
|
||||
|
||||
|
||||
from multiaddr import Multiaddr
|
||||
@ -11,7 +8,6 @@ from .id import ID
|
||||
|
||||
|
||||
class IAddrBook(ABC):
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import hashlib
|
||||
from typing import (
|
||||
Union,
|
||||
)
|
||||
from typing import Union
|
||||
|
||||
import base58
|
||||
|
||||
@ -44,7 +42,7 @@ class ID:
|
||||
__repr__ = __str__
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
#pylint: disable=protected-access
|
||||
# pylint: disable=protected-access
|
||||
if not isinstance(other, ID):
|
||||
return NotImplemented
|
||||
return self._id_str == other._id_str
|
||||
@ -57,7 +55,7 @@ def id_b58_encode(peer_id: ID) -> str:
|
||||
"""
|
||||
return a b58-encoded string
|
||||
"""
|
||||
#pylint: disable=protected-access
|
||||
# pylint: disable=protected-access
|
||||
return base58.b58encode(peer_id.get_raw_id()).decode()
|
||||
|
||||
|
||||
@ -84,7 +82,8 @@ def id_from_public_key(key: RsaKey) -> ID:
|
||||
def id_from_private_key(key: RsaKey) -> ID:
|
||||
return id_from_public_key(key.publickey())
|
||||
|
||||
|
||||
def digest(data: Union[str, bytes]) -> bytes:
|
||||
if isinstance(data, str):
|
||||
data = data.encode('utf8')
|
||||
data = data.encode("utf8")
|
||||
return hashlib.sha1(data).digest()
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Sequence,
|
||||
)
|
||||
from typing import Any, Dict, List, Sequence
|
||||
|
||||
from multiaddr import Multiaddr
|
||||
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
Sequence,
|
||||
)
|
||||
from typing import Any, List, Sequence
|
||||
|
||||
from multiaddr import Multiaddr
|
||||
|
||||
@ -11,7 +7,6 @@ from .peermetadata_interface import IPeerMetadata
|
||||
|
||||
|
||||
class IPeerData(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def get_protocols(self) -> List[str]:
|
||||
"""
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
from typing import (
|
||||
List,
|
||||
)
|
||||
from typing import List
|
||||
|
||||
import multiaddr
|
||||
|
||||
from .id import (
|
||||
ID,
|
||||
id_b58_decode,
|
||||
)
|
||||
from .id import ID, id_b58_decode
|
||||
from .peerdata import PeerData
|
||||
|
||||
|
||||
@ -31,7 +26,9 @@ def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
|
||||
|
||||
parts = addr.split()
|
||||
if not parts:
|
||||
raise InvalidAddrError(f"`parts`={parts} should at least have a protocol `P_P2P`")
|
||||
raise InvalidAddrError(
|
||||
f"`parts`={parts} should at least have a protocol `P_P2P`"
|
||||
)
|
||||
|
||||
p2p_part = parts[-1]
|
||||
last_protocol_code = p2p_part.protocols()[0].code
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import (
|
||||
Any,
|
||||
)
|
||||
from typing import Any
|
||||
|
||||
from .id import (
|
||||
ID,
|
||||
)
|
||||
from .id import ID
|
||||
|
||||
|
||||
class IPeerMetadata(ABC):
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Sequence,
|
||||
)
|
||||
from typing import Any, Dict, List, Optional, Sequence
|
||||
|
||||
from multiaddr import Multiaddr
|
||||
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
from abc import abstractmethod
|
||||
from typing import (
|
||||
List,
|
||||
Sequence,
|
||||
)
|
||||
from typing import List, Sequence
|
||||
|
||||
|
||||
from .addrbook_interface import IAddrBook
|
||||
@ -12,7 +9,6 @@ from .peermetadata_interface import IPeerMetadata
|
||||
|
||||
|
||||
class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
|
||||
def __init__(self) -> None:
|
||||
IPeerMetadata.__init__(self)
|
||||
IAddrBook.__init__(self)
|
||||
|
||||
Reference in New Issue
Block a user