From 1ec8380992cb3c49dd4a6db27389023b26048afc Mon Sep 17 00:00:00 2001 From: Manuel Schmidt Date: Tue, 5 Dec 2023 13:32:12 +0000 Subject: [PATCH] Add typehints --- src/blockperf/app.py | 10 +++++----- src/blockperf/blocksample.py | 2 +- src/blockperf/mqtt.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/blockperf/app.py b/src/blockperf/app.py index 6594bff..b11ced8 100644 --- a/src/blockperf/app.py +++ b/src/blockperf/app.py @@ -27,14 +27,14 @@ class App: start_time: int # holds a dictionairy for each kind of events for each block_hash - logevents = {} + logevents: dict = {} # the list of all published hashes, to not publish a hash twice - published_blocks = [] + published_blocks: list = [] # Stores the last X hashes before they are deleted from logevents and published_blocks - working_hashes = collections.deque() + working_hashes: collections.deque = collections.deque() def __init__(self, config: AppConfig) -> None: - self.q = queue.Queue(maxsize=50) + self.q: queue.Queue = queue.Queue(maxsize=50) self.app_config = config self.start_time = int(datetime.now().timestamp()) @@ -352,7 +352,7 @@ def logevents_logfile(self): break # Yield all events - logger.debug(f"Found {len(logevents)} logevents") + # logger.debug(f"Found {len(logevents)} logevents") yield from logevents # If no new_lines are returned check if the symlink changed diff --git a/src/blockperf/blocksample.py b/src/blockperf/blocksample.py index 4627c36..f6f3a46 100644 --- a/src/blockperf/blocksample.py +++ b/src/blockperf/blocksample.py @@ -74,7 +74,7 @@ class BlockSample: # Take deltaq.G from that FetchRequest """ - trace_events = list() + trace_events: list = [] def __init__(self, events: list) -> None: """Creates LogEvent and orders the events by at field""" diff --git a/src/blockperf/mqtt.py b/src/blockperf/mqtt.py index 27b1ff3..b76f0d4 100644 --- a/src/blockperf/mqtt.py +++ b/src/blockperf/mqtt.py @@ -50,12 +50,12 @@ def on_connect(self, client, userdata, flags, reasonCode, properties): def on_connect_fail(self, client, obj): logger.warning("Connection Failed") - def on_disconnect(self, client, userdata, reasonCode, properties) -> None: + def on_disconnect(self, client, userdata, reasonCode, properties) -> None: # type: ignore """Called when disconnected from broker See paho.mqtt.client.py on_disconnect()""" logger.warning("Connection disconnected %s", reasonCode) - def on_publish(self, client, userdata, mid) -> None: + def on_publish(self, client, userdata, mid) -> None: # type: ignore """Called when a message is actually received by the broker. See paho.mqtt.client.py on_publish()""" # There should be a way to know which messages belongs to which @@ -74,7 +74,7 @@ def __on_log(self, client, userdata, level, buf): """ logger.debug("%s - %s", level, buf) - def publish(self, topic: str, payload: dict): + def publish(self, topic: str, payload: dict): # type: ignore """ MQTTClient publish: