Skip to content

Commit

Permalink
Fix mypy complaints for zino1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Sep 11, 2023
1 parent 0202712 commit 0a6c1a1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/zinolib/zino1.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"""

from datetime import datetime, timezone
from typing import List, Dict, Union, TypedDict, Optional
from typing import Iterable, List, Dict, Union, TypedDict, Optional

from .event_types import EventType, Event, EventEngine, HistoryEntry, LogEntry, AdmState

Expand Down Expand Up @@ -92,7 +92,7 @@ def get_attrlist(session, event_id: int):
return session.get_raw_attributes(event_id)

@classmethod
def attrlist_to_attrdict(cls, attrlist: List[str]):
def attrlist_to_attrdict(cls, attrlist: Iterable[str]):
"""Translate a wire protocol dump of a single event
The dump is a list of lines of the format:
Expand Down Expand Up @@ -134,7 +134,7 @@ def get_history(session, event_id: int):
return session.get_raw_history(event_id).data

@classmethod
def parse_response(cls, history_data: List[str]):
def parse_response(cls, history_data: Iterable[str]) -> list[HistoryDict]:
"""
Input:
Expand Down Expand Up @@ -180,7 +180,7 @@ def parse_response(cls, history_data: List[str]):
return history_list

@classmethod
def add(cls, session, message: str, event: EventType):
def add(cls, session, message: str, event: EventType) -> Optional[EventType]:
success = session.add_history(event.id, message)
if success:
# fetch history
Expand All @@ -190,15 +190,16 @@ def add(cls, session, message: str, event: EventType):
if new_history != event.history:
event.history = new_history
return event
return None


class LogAdapter:
@staticmethod
def get_log(session, event_id: int):
def get_log(session, event_id: int) -> list[str]:
return session.get_raw_log(event_id).data

@staticmethod
def parse_response(log_data: List[str]) -> List[LogDict]:
def parse_response(log_data: Iterable[str]) -> list[LogDict]:
"""
Input:
[
Expand Down

0 comments on commit 0a6c1a1

Please sign in to comment.