-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Fix issue 8894 with uk_transport component if no next_buses or next_trains #9046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes #8894
Out of curiosity, how the "no more trains/bus" renders on the front-end? The |
_delta_mins, [bus['scheduled'] for bus in self._next_buses] | ||
)) | ||
else: | ||
self._state = STATE_UNKNOWN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use STATE_UNKNOWN
, instead set it to None
[train['scheduled'] for train in self._next_trains] | ||
)) | ||
if self._next_trains: | ||
self._state = min(map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can merge the map into the list comprehension:
min(_delta_mins(train['scheduled']) for train in self._next_trains)
[train['scheduled'] for train in self._next_trains] | ||
)) | ||
else: | ||
self._state = STATE_UNKNOWN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use None
Awesome, thanks! 🐬 |
Fixes #8894
Description:
Fixes #8894 where an error was thrown if there were no next-buses or trains
Related issue (if applicable): fixes #8894
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass