Skip to content

Commit

Permalink
Update type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-zenk committed Sep 2, 2022
1 parent 40cf4e0 commit 4e1cd1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions onboardapis/trains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ def number(self) -> str:

@property
@abc.abstractmethod
def stations(self) -> Dict[str, Station]:
def stations(self) -> Dict[Any, Station]:
"""
The stations that this train passes through
The stations that this train passes through returned as a dict with the station ID as the key
:return: The stations
:rtype: Dict[str, Station]
Expand Down
9 changes: 5 additions & 4 deletions onboardapis/trains/germany/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def number(self) -> str:
return self._dynamic_data.load("trip", {}).get('trip', {}).get('vzn')

@property
def stations(self) -> Dict[Any, Station]:
def stations(self) -> Dict[str, Station]:
# Each stations connecting trains require an additional request
# So use a LazyStation to only request the connections when needed
return {
Expand Down Expand Up @@ -186,7 +186,7 @@ def all_delay_reasons(self) -> Dict[str, Optional[str]]:
Get all delay reasons for the current trip
:return: A dictionary of delay reasons
:rtype: Dict[str, str]
:rtype: Dict[str, Optional[str]]
"""
return {
stop.get('station', {}).get('evaNr', None): some_or_default(stop.get('delayReason', {}).get('text', None))
Expand Down Expand Up @@ -252,6 +252,7 @@ def internet_connection(self) -> Tuple[
datetime.timedelta(
seconds=int(self._dynamic_data.load("status", {}).get('connectivity', {}).get('remainingTimeSeconds'))
)
if self._dynamic_data.load("status", {}).get('connectivity', {}).get('remainingTimeSeconds', '') != ""
else None
if some_or_default(
self._dynamic_data.load("status", {}).get('connectivity', {}).get('remainingTimeSeconds', '')
) is not None else None
)

0 comments on commit 4e1cd1b

Please sign in to comment.