Fixed typing

This commit is contained in:
Profitroll 2022-10-05 14:19:39 +02:00
parent 366497d8fb
commit 4136bbcddb
6 changed files with 30 additions and 13 deletions

View File

@ -1,2 +1,8 @@
class Board(): class Board():
pass
class BoardArrival(Board):
pass
class BoardDeparture(Board):
pass pass

View File

@ -3,4 +3,5 @@ from .rt_mode import RealTimeMode
from .lang import Language from .lang import Language
from .location_type import LocationType from .location_type import LocationType
from .selection_mode import SelectionMode from .selection_mode import SelectionMode
from .filter_mode import FilterMode from .filter_mode import FilterMode
from .board_type import BoardArrivalType, BoardDepartureType

View File

@ -1,12 +1,17 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Union from typing import Union
from pyrmv.classes.Board import Board from pyrmv.classes.Board import BoardArrival
from pyrmv.classes.Stop import Stop, StopTrip from pyrmv.classes.Stop import Stop, StopTrip
from pyrmv.enums.board_type import BoardArrivalType from pyrmv.enums.board_type import BoardArrivalType
from pyrmv.errors.not_ready import NotReadyYetError from pyrmv.errors.not_ready import NotReadyYetError
from pyrmv.raw import board_arrival as raw_board_arrival from pyrmv.raw import board_arrival as raw_board_arrival
from pyrmv.utility.find_exception import find_exception from pyrmv.utility.find_exception import find_exception
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
def board_arrival( def board_arrival(
access_id: str, access_id: str,
@ -20,8 +25,8 @@ def board_arrival(
operators: Union[str, list] = None, operators: Union[str, list] = None,
lines: Union[str, list] = None, lines: Union[str, list] = None,
passlist: bool = False, passlist: bool = False,
board_type: Union[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR, board_type: Literal[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR,
) -> Board: ) -> BoardArrival:
"""Method returns a board with arriving transport. """Method returns a board with arriving transport.
More detailed request is available as `raw.board_arrival()`, however returns `dict` instead of `Board`. More detailed request is available as `raw.board_arrival()`, however returns `dict` instead of `Board`.
@ -41,7 +46,7 @@ def board_arrival(
* board_type (`Union[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION]`, optional): Set the station arrival board type to be used. Defaults to `BoardArrivalType.ARR`. * board_type (`Union[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION]`, optional): Set the station arrival board type to be used. Defaults to `BoardArrivalType.ARR`.
### Returns: ### Returns:
* Board: Instance of Board object. * BoardArrival: Instance of BoardArrival object.
""" """
board_raw = raw_board_arrival( board_raw = raw_board_arrival(
@ -62,4 +67,4 @@ def board_arrival(
find_exception(board_raw) find_exception(board_raw)
raise NotReadyYetError() raise NotReadyYetError()
# return Board(board_raw) # return BoardArrival(board_raw)

View File

@ -1,12 +1,17 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Union from typing import Union
from pyrmv.classes.Board import Board from pyrmv.classes.Board import BoardDeparture
from pyrmv.classes.Stop import Stop, StopTrip from pyrmv.classes.Stop import Stop, StopTrip
from pyrmv.enums.board_type import BoardDepartureType from pyrmv.enums.board_type import BoardDepartureType
from pyrmv.errors.not_ready import NotReadyYetError from pyrmv.errors.not_ready import NotReadyYetError
from pyrmv.raw import board_departure as raw_board_departure from pyrmv.raw import board_departure as raw_board_departure
from pyrmv.utility.find_exception import find_exception from pyrmv.utility.find_exception import find_exception
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
def board_departure( def board_departure(
access_id: str, access_id: str,
@ -20,8 +25,8 @@ def board_departure(
operators: Union[str, list] = None, operators: Union[str, list] = None,
lines: Union[str, list] = None, lines: Union[str, list] = None,
passlist: bool = False, passlist: bool = False,
board_type: Union[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP, board_type: Literal[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP,
) -> Board: ) -> BoardDeparture:
"""Method returns a board with departing transport. """Method returns a board with departing transport.
More detailed request is available as `raw.board_departure()`, however returns `dict` instead of `Board`. More detailed request is available as `raw.board_departure()`, however returns `dict` instead of `Board`.
@ -41,7 +46,7 @@ def board_departure(
* board_type (`Union[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION]`, optional): Set the station departure board type to be used. Defaults to `BoardDepartureType.DEP`. * board_type (`Union[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION]`, optional): Set the station departure board type to be used. Defaults to `BoardDepartureType.DEP`.
### Returns: ### Returns:
* Board: Instance of Board object. * BoardDeparture: Instance of BoardDeparture object.
""" """
board_raw = raw_board_departure( board_raw = raw_board_departure(
@ -62,4 +67,4 @@ def board_departure(
find_exception(board_raw) find_exception(board_raw)
raise NotReadyYetError() raise NotReadyYetError()
# return Board(board_raw) # return BoardDeparture(board_raw)

View File

@ -39,7 +39,7 @@ def stop_by_coords(
* selection_mode (`Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N]`, **optional**): Selection mode for locations. `SelectionMode.SLCT_N`: Not selectable, `SelectionMode.SLCT_A`: Selectable. Defaults to `None`. * selection_mode (`Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N]`, **optional**): Selection mode for locations. `SelectionMode.SLCT_N`: Not selectable, `SelectionMode.SLCT_A`: Selectable. Defaults to `None`.
### Returns: ### Returns:
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs. * List[Stop]: List of Stop objects. Empty list if none found.
""" """
if selection_mode == None: if selection_mode == None:

View File

@ -49,7 +49,7 @@ def stop_by_name(
* filter_mode (`Literal[FilterMode.DIST_PERI, FilterMode.EXCL_PERI, FilterMode.SLCT_PERI]`, **optional**): Filter modes for nearby searches. Defaults to `FilterMode.DIST_PERI`. * filter_mode (`Literal[FilterMode.DIST_PERI, FilterMode.EXCL_PERI, FilterMode.SLCT_PERI]`, **optional**): Filter modes for nearby searches. Defaults to `FilterMode.DIST_PERI`.
### Returns: ### Returns:
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs. * List[Stop]: List of Stop objects. Empty list if none found.
""" """
if selection_mode == None: if selection_mode == None: