Skip to content

Commit

Permalink
fixed untyped defs in cloudinit analyze
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulganiyy authored and abdulganiyy committed Oct 29, 2024
1 parent 2e1486e commit e609e0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cloudinit/analyze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion cloudinit/analyze/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."]
Expand Down
20 changes: 16 additions & 4 deletions cloudinit/analyze/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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()
Expand All @@ -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.
Expand Down

0 comments on commit e609e0d

Please sign in to comment.