Apply suggestions from code review

Co-Authored-By: NIC Lin <twedusuck@gmail.com>
This commit is contained in:
Kevin Mai-Husan Chia 2019-07-20 22:38:56 +08:00 committed by mhchia
parent a2d1aadf25
commit 085a5e7526
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A

View File

@ -13,10 +13,10 @@ class PeerInfo:
def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
if not addr:
raise InvalidAddrError("addr should not be None")
raise InvalidAddrError("`addr` should not be `None`")
if not isinstance(addr, multiaddr.Multiaddr):
raise InvalidAddrError(f"addr={addr} should be in type Multiaddr")
raise InvalidAddrError(f"`addr`={addr} should be of type `Multiaddr`")
parts = addr.split()
if not parts:
@ -26,7 +26,7 @@ def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
last_protocol_code = p2p_part.protocols()[0].code
if last_protocol_code != multiaddr.protocols.P_P2P:
raise InvalidAddrError(
f"the last protocol should be P_P2P instead of {last_protocol_code}"
f"The last protocol should be `P_P2P` instead of `{last_protocol_code}`"
)
# make sure the /p2p value parses as a peer.ID