1 """Utils for NextBus integration module."""
3 from typing
import Any, NamedTuple
6 def listify(maybe_list: Any) -> list[Any]:
7 """Return list version of whatever value is passed in.
9 This is used to provide a consistent way of interacting with the JSON
10 results from the API. There are several attributes that will either missing
11 if there are no values, a single dictionary if there is only one value, and
12 a list if there are multiple.
14 if maybe_list
is None:
16 if isinstance(maybe_list, list):
22 """Return the first item out of a list or returns back the input."""
23 if isinstance(maybe_list, list)
and maybe_list:
30 """NamedTuple for a route and stop combination."""
Any maybe_first(list[Any]|None maybe_list)
list[Any] listify(Any maybe_list)