Skip to content
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

Fix mypy errors in shuttle.py #196

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions pittapi/shuttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from typing import Any


JSON = dict[str, Any]

API_KEY = "8882812681"
VEHICLE_POINTS_URL = "http://www.pittshuttle.com/Services/JSONPRelay.svc/GetMapVehiclePoints"
ARRIVAL_TIMES_URL = "http://www.pittshuttle.com/Services/JSONPRelay.svc/GetRouteStopArrivals"
Expand All @@ -30,29 +32,33 @@
sess = requests.session()


def get_map_vehicle_points(api_key: str = API_KEY) -> dict[str, Any]:
def get_map_vehicle_points(api_key: str = API_KEY) -> JSON:
"""Return the map location for all active vehicles."""
payload = {"ApiKey": api_key}
response = sess.get(VEHICLE_POINTS_URL, params=payload)
return response.json()
response_json: JSON = response.json()
return response_json


def get_route_stop_arrivals(api_key: str = API_KEY, times_per_stop: int = 1) -> dict[str, Any]:
def get_route_stop_arrivals(api_key: str = API_KEY, times_per_stop: int = 1) -> JSON:
"""Return stop arrival times for all vehicles."""
payload = {"ApiKey": api_key, "TimesPerStopString": times_per_stop}
payload = {"ApiKey": api_key, "TimesPerStopString": str(times_per_stop)}
response = sess.get(ARRIVAL_TIMES_URL, params=payload)
return response.json()
response_json: JSON = response.json()
return response_json


def get_vehicle_route_stop_estimates(vehicle_id: str, quantity: int = 2) -> dict[str, Any]:
def get_vehicle_route_stop_estimates(vehicle_id: str, quantity: int = 2) -> JSON:
"""Return {quantity} stop estimates for all active vehicles."""
payload = {"vehicleIdStrings": vehicle_id, "quantity": str(quantity)}
response = sess.get(STOP_ESTIMATES_URL, params=payload)
return response.json()
response_json: JSON = response.json()
return response_json


def get_routes(api_key: str = API_KEY) -> dict[str, Any]:
def get_routes(api_key: str = API_KEY) -> JSON:
"""Return the routes with Vehicle Route Name, Vehicle ID, and all stops, etc."""
payload = {"ApiKey": api_key}
response = sess.get(ROUTES_URL, params=payload)
return response.json()
response_json: JSON = response.json()
return response_json