From e609e0d052faea2b8dff81864c8ad431ccedd3b4 Mon Sep 17 00:00:00 2001 From: abdulganiyy Date: Tue, 29 Oct 2024 12:16:49 +0100 Subject: [PATCH] fixed untyped defs in cloudinit analyze --- cloudinit/analyze/__init__.py | 4 +++- cloudinit/analyze/dump.py | 5 ++++- cloudinit/analyze/show.py | 20 ++++++++++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/cloudinit/analyze/__init__.py b/cloudinit/analyze/__init__.py index 4ff2af72e09..efa3f947577 100644 --- a/cloudinit/analyze/__init__.py +++ b/cloudinit/analyze/__init__.py @@ -12,7 +12,9 @@ from cloudinit.atomic_helper import json_dumps -def get_parser(parser: argparse.ArgumentParser = None) -> argparse.ArgumentParser: +def get_parser( + parser: argparse.ArgumentParser = None +) -> argparse.ArgumentParser: if not parser: parser = argparse.ArgumentParser( prog="cloudinit-analyze", diff --git a/cloudinit/analyze/dump.py b/cloudinit/analyze/dump.py index 9d63113ecfa..4673f93a4f4 100644 --- a/cloudinit/analyze/dump.py +++ b/cloudinit/analyze/dump.py @@ -165,7 +165,10 @@ def parse_ci_logline(line: str) -> Optional[Dict[str, Union[str, float]]]: return event -def dump_events(cisource: Optional[object] = None, rawdata: Optional[str] = None) -> Tuple[List[Dict[str, Union[str, float]]], List[str]]: +def dump_events( + cisource: Optional[object] = None, + rawdata: Optional[str] = None +) -> Tuple[List[Dict[str, Union[str, float]]], List[str]]: events = [] event = None CI_EVENT_MATCHES = ["start:", "finish:", "Cloud-init v."] diff --git a/cloudinit/analyze/show.py b/cloudinit/analyze/show.py index ccbd7bb151f..b9ea9cc7da0 100644 --- a/cloudinit/analyze/show.py +++ b/cloudinit/analyze/show.py @@ -95,11 +95,18 @@ def delta_seconds(t1: datetime.datetime, t2: datetime.datetime) -> float: return (t2 - t1).total_seconds() -def event_duration(start: Dict[str, Union[str, float]], finish: Dict[str, Union[str, float]]) -> float: +def event_duration( + start: Dict[str, Union[str, float]], + finish: Dict[str, Union[str, float]] +) -> float: return delta_seconds(event_datetime(start), event_datetime(finish)) -def event_record(start_time:datetime.datetime, start: Dict[str, Union[str, float]], finish: Dict[str, Union[str, float]]) -> Dict[str, Union[str, float]]: +def event_record( + start_time:datetime.datetime, + start: Dict[str, Union[str, float]], + finish: Dict[str, Union[str, float]] +) -> Dict[str, Union[str, float]]: record = finish.copy() record.update( { @@ -329,7 +336,10 @@ def generate_records( return boot_records -def show_events(events: List[Dict[str, Union[str, float]]], print_format: str) -> List[List[str]]: +def show_events( + events: List[Dict[str, Union[str, float]]], + print_format: str +) -> List[List[str]]: """ A passthrough method that makes it easier to call generate_records() @@ -342,7 +352,9 @@ def show_events(events: List[Dict[str, Union[str, float]]], print_format: str) - return generate_records(events, print_format=print_format) -def load_events_infile(infile: TextIO) -> Tuple[Optional[List[Dict[str, Union[str, float]]]], str]: +def load_events_infile( + infile: TextIO +) -> Tuple[Optional[List[Dict[str, Union[str, float]]]], str]: """ Takes in a log file, read it, and convert to json.