From 38865cb200718f64fa54f35d64538a88c6d3302d Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Mon, 22 Jan 2024 07:52:29 +0000 Subject: [PATCH] Add black dependency and format code with it --- dev_requirements.txt | 3 ++- src/blockperf/cli.py | 19 +++++-------------- src/blockperf/mqtt.py | 6 ++++-- src/blockperf/nodelogs.py | 8 ++++++-- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/dev_requirements.txt b/dev_requirements.txt index cffeec6..5c43051 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,2 +1,3 @@ pytest -pytest-cov \ No newline at end of file +pytest-cov +black diff --git a/src/blockperf/cli.py b/src/blockperf/cli.py index 167f26e..391950f 100644 --- a/src/blockperf/cli.py +++ b/src/blockperf/cli.py @@ -34,8 +34,8 @@ def setup_logger(debug: bool): }, "extra": { "format": "%(asctime)-16s %(name)-8s %(filename)-12s %(lineno)-6s %(funcName)-30s %(levelname)-8s %(message)s", - "datefmt": "%m-%d %H:%M:%S" - } + "datefmt": "%m-%d %H:%M:%S", + }, }, "handlers": { "console": { @@ -54,16 +54,8 @@ def setup_logger(debug: bool): # "backupCount": 2, # } }, - "loggers": { - "blockperf": { - "level": "DEBUG", - "handlers": [] - } - }, - "root": { - "level": level, - "handlers": ["console"] - } + "loggers": {"blockperf": {"level": "DEBUG", "handlers": []}}, + "root": {"level": level, "handlers": ["console"]}, } dictConfig(logger_config) @@ -74,8 +66,7 @@ def setup_argparse(): parser.add_argument( "command", help="Command to run blockperf with", choices=["run"] ) - parser.add_argument( - "--debug", help="Write more debug output", action="store_true") + parser.add_argument("--debug", help="Write more debug output", action="store_true") return parser.parse_args() diff --git a/src/blockperf/mqtt.py b/src/blockperf/mqtt.py index b43f234..27b1ff3 100644 --- a/src/blockperf/mqtt.py +++ b/src/blockperf/mqtt.py @@ -5,6 +5,7 @@ import json from paho.mqtt.client import MQTTMessageInfo from paho.mqtt.properties import Properties as Properties + try: import paho.mqtt.client as mqtt from paho.mqtt.properties import Properties @@ -31,7 +32,7 @@ def __init__( client_keyfile: str, host: str, port: int, - keepalive: int + keepalive: int, ) -> None: super().__init__(protocol=mqtt.MQTTv5) self.tls_set( @@ -86,7 +87,8 @@ def publish(self, topic: str, payload: dict): logger.info("Publishing sample to %s", topic) # call the actuall clients publish method and receive the message_info message_info: MQTTMessageInfo = super().publish( - topic=topic, payload=json_payload, properties=publish_properties) + topic=topic, payload=json_payload, properties=publish_properties + ) # The message_info might not yet have been published, # wait_for_publish() blocks until TIMEOUT for that message to be published message_info.wait_for_publish(PUBLISH_TIMEOUT) diff --git a/src/blockperf/nodelogs.py b/src/blockperf/nodelogs.py index 9948662..af17df4 100644 --- a/src/blockperf/nodelogs.py +++ b/src/blockperf/nodelogs.py @@ -157,8 +157,12 @@ def __init__(self, event_data: dict) -> None: ): self.local_addr = self.data.get("peer", {}).get("local", {}).get("addr", "") self.local_port = self.data.get("peer", {}).get("local", {}).get("port", "") - self.remote_addr = self.data.get("peer", {}).get("remote", {}).get("addr", "") - self.remote_port = self.data.get("peer", {}).get("remote", {}).get("port", "") + self.remote_addr = ( + self.data.get("peer", {}).get("remote", {}).get("addr", "") + ) + self.remote_port = ( + self.data.get("peer", {}).get("remote", {}).get("port", "") + ) def __repr__(self): _kind = self.kind.value