Skip to content

Commit

Permalink
fixed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mg98 committed Oct 24, 2024
1 parent 5ffb981 commit 0a77262
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ipv8/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,15 @@ def add_message_handler(self, msg_num: int | type[Payload], callback: MessageHan
actual_msg_num: int = 256
if not isinstance(msg_num, int):
if not hasattr(msg_num, "msg_id"):
raise RuntimeError("Attempted to add a handler for Payload %s, which does not specify a msg_id!"
% msg_num)
raise RuntimeError(f"Attempted to add a handler for Payload {msg_num}, which does not specify a msg_id!")
actual_msg_num = cast(int, msg_num.msg_id) # type: ignore[attr-defined]
else:
if msg_num < 0 or msg_num > 255:
raise RuntimeError("Attempted to add a handler for message number %d, which is not a byte!" % msg_num)
raise RuntimeError(f"Attempted to add a handler for message number {msg_num}, which is not a byte!")
actual_msg_num = msg_num

if self.decode_map[actual_msg_num]:
raise RuntimeError("Attempted to add a handler for message number %d, already mapped to %s!" %
(actual_msg_num, self.decode_map[actual_msg_num]))
raise RuntimeError(f"Attempted to add a handler for message number {actual_msg_num}, already mapped to {self.decode_map[actual_msg_num]}!")
self.decode_map[actual_msg_num] = callback

def on_deprecated_message(self, source_address: Address, data: bytes) -> None:
Expand Down

0 comments on commit 0a77262

Please sign in to comment.