Skip to content

Commit

Permalink
cubestat: some type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
okuvshynov committed Aug 7, 2024
1 parent 4d32585 commit c087384
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cubestat/cubestat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, stdscr, args):
self.input_handler = InputHandler(self)
self.data_manager = DataManager(args.buffer_size)

def do_read(self, context):
def do_read(self, context) -> None:
updates = []
for group, metric in self.metrics.items():
datapoint = metric.read(context)
Expand All @@ -59,11 +59,11 @@ def do_read(self, context):
if self.h_shift > 0:
self.h_shift += 1

def max_val(self, metric, title, data_slice):
def max_val(self, metric, title: str, data_slice: list) -> float:
max_value, _ = metric.format(title, data_slice, [-1])
return max_value

def _ruler_values(self, metric, title, idxs, data):
def _ruler_values(self, metric, title: str, idxs: list, data: list) -> list:
if self.view == ViewMode.off:
return []
idxs = [idx for idx in idxs if idx < len(data)]
Expand All @@ -73,7 +73,7 @@ def _ruler_values(self, metric, title, idxs, data):
idxs = idxs[:1]
return list(zip(idxs, formatted_values))

def render(self):
def render(self) -> None:
with self.lock:
if self.snapshots_rendered > self.snapshots_observed:
logging.fatal('self.snapshots_rendered > self.snapshots_observed')
Expand Down
2 changes: 1 addition & 1 deletion cubestat/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def init_group():

self.data = collections.defaultdict(init_group)

# TODO: UI-related things should be moved out of here
# Returns a slice of data row which will be visible on the screen
def get_slice(self, series, h_shift, chart_width):
data_length = len(series) - h_shift if h_shift > 0 else len(series)
index = max(0, data_length - chart_width)
Expand Down

0 comments on commit c087384

Please sign in to comment.