Skip to content

Commit

Permalink
Merge pull request #2 from elliotwutingfeng/docstring
Browse files Browse the repository at this point in the history
Shift type comments
  • Loading branch information
elliotwutingfeng authored Dec 29, 2023
2 parents a951df1 + 9559506 commit f475739
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions train_arrival.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
REFERER = "http://journey.smrt.com.sg/journey/station_info/" # Credits: https://github.com/cheeaun/railrouter-sg


def _is_str_or_unicode(s):
# type: (Any) -> bool
def _is_str_or_unicode(s): # type: (Any) -> bool
"""Check if `s` is str type in both Python 2 and 3, else if it is
unicode type in Python 2.
Expand All @@ -42,8 +41,7 @@ def _is_str_or_unicode(s):
return is_python2 and type(s).__name__ == "unicode"


def _get(url, params=None):
# type: (str, dict[str, str] | None) -> str
def _get(url, params=None): # type: (str, dict[str, str] | None) -> str
"""Make a GET request to `url` with optional query parameters `params`.
Return the body as a string if it is a valid JSON string, otherwise {}.
Expand Down Expand Up @@ -75,8 +73,7 @@ def _get(url, params=None):
return "{}"


def get_all_station_info():
# type: () -> str
def get_all_station_info(): # type: () -> str
"""Get all train station information from SMRT API.
Returns:
Expand All @@ -85,8 +82,7 @@ def get_all_station_info():
return _get("https://connect.smrt.wwprojects.com/smrt/api/stations")


def get_all_station_names():
# type: () -> list[str]
def get_all_station_names(): # type: () -> list[str]
"""Get all train station names from SMRT API.
Returns:
Expand All @@ -107,8 +103,7 @@ def get_all_station_names():
return sorted(station_names)


def get_train_arrival_time_by_id(station_name):
# type: (str) -> str
def get_train_arrival_time_by_id(station_name): # type: (str) -> str
"""Get train arrival times for a given train station as a JSON string.
Args:
Expand Down Expand Up @@ -142,8 +137,7 @@ def get_train_arrival_time_by_id(station_name):
return '{"results": []}'


def get_all_train_arrival_time(limit=None):
# type: (int | None) -> str
def get_all_train_arrival_time(limit=None): # type: (int | None) -> str
"""Get train arrival times for all train stations as a JSON string.
Warning: Estimated execution time is at least 5 minutes.
Expand Down

0 comments on commit f475739

Please sign in to comment.