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():
pass
class BoardArrival(Board):
pass
class BoardDeparture(Board):
pass

View File

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

View File

@ -1,12 +1,17 @@
from datetime import datetime, timedelta
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.enums.board_type import BoardArrivalType
from pyrmv.errors.not_ready import NotReadyYetError
from pyrmv.raw import board_arrival as raw_board_arrival
from pyrmv.utility.find_exception import find_exception
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
def board_arrival(
access_id: str,
@ -20,8 +25,8 @@ def board_arrival(
operators: Union[str, list] = None,
lines: Union[str, list] = None,
passlist: bool = False,
board_type: Union[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR,
) -> Board:
board_type: Literal[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR,
) -> BoardArrival:
"""Method returns a board with arriving transport.
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`.
### Returns:
* Board: Instance of Board object.
* BoardArrival: Instance of BoardArrival object.
"""
board_raw = raw_board_arrival(
@ -62,4 +67,4 @@ def board_arrival(
find_exception(board_raw)
raise NotReadyYetError()
# return Board(board_raw)
# return BoardArrival(board_raw)

View File

@ -1,12 +1,17 @@
from datetime import datetime, timedelta
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.enums.board_type import BoardDepartureType
from pyrmv.errors.not_ready import NotReadyYetError
from pyrmv.raw import board_departure as raw_board_departure
from pyrmv.utility.find_exception import find_exception
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
def board_departure(
access_id: str,
@ -20,8 +25,8 @@ def board_departure(
operators: Union[str, list] = None,
lines: Union[str, list] = None,
passlist: bool = False,
board_type: Union[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP,
) -> Board:
board_type: Literal[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP,
) -> BoardDeparture:
"""Method returns a board with departing transport.
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`.
### Returns:
* Board: Instance of Board object.
* BoardDeparture: Instance of BoardDeparture object.
"""
board_raw = raw_board_departure(
@ -62,4 +67,4 @@ def board_departure(
find_exception(board_raw)
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`.
### 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:

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`.
### 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: