From fa2a70efbf7b76904bede2d56d5b25a057f6cc3f Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 18 Aug 2024 22:51:57 +0200 Subject: [PATCH 1/5] Added PlatformType and PlatformTypeType (for #4) --- src/pyrmv/classes/__init__.py | 1 + src/pyrmv/classes/platform_type.py | 17 +++++++++ src/pyrmv/enums/__init__.py | 1 + src/pyrmv/enums/platform_type_type.py | 51 +++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 src/pyrmv/classes/platform_type.py create mode 100644 src/pyrmv/enums/platform_type_type.py diff --git a/src/pyrmv/classes/__init__.py b/src/pyrmv/classes/__init__.py index c87171b..356d8ea 100644 --- a/src/pyrmv/classes/__init__.py +++ b/src/pyrmv/classes/__init__.py @@ -3,6 +3,7 @@ from .gis import Gis from .journey import Journey from .leg import Leg from .message import Channel, Message, Url +from .platform_type import PlatformType from .stop import Stop, StopTrip from .ticket import Ticket from .trip import Trip diff --git a/src/pyrmv/classes/platform_type.py b/src/pyrmv/classes/platform_type.py new file mode 100644 index 0000000..a1afe49 --- /dev/null +++ b/src/pyrmv/classes/platform_type.py @@ -0,0 +1,17 @@ +from typing import Any, Mapping, Union + +from pyrmv.enums.platform_type_type import PlatformTypeType + + +class PlatformType: + """Platform information.""" + + def __init__(self, data: Mapping[str, Any]): + self.type: PlatformTypeType = ( + PlatformTypeType.U if "type" not in data else PlatformTypeType(data.get("type")) + ) + self.text: Union[str, None] = data.get("text") + self.hidden: bool = bool(data.get("hidden")) + self.lon: float = data["lon"] + self.lat: float = data["lat"] + self.alt: int = data["alt"] diff --git a/src/pyrmv/enums/__init__.py b/src/pyrmv/enums/__init__.py index 92cffb6..d8d4b74 100644 --- a/src/pyrmv/enums/__init__.py +++ b/src/pyrmv/enums/__init__.py @@ -4,6 +4,7 @@ from .board_type import BoardArrivalType, BoardDepartureType from .filter_mode import FilterMode from .lang import Language from .location_type import LocationType +from .platform_type_type import PlatformTypeType from .product import Product from .rt_mode import RealTimeMode from .search_mode import SearchMode diff --git a/src/pyrmv/enums/platform_type_type.py b/src/pyrmv/enums/platform_type_type.py new file mode 100644 index 0000000..4658bde --- /dev/null +++ b/src/pyrmv/enums/platform_type_type.py @@ -0,0 +1,51 @@ +from enum import Enum, auto + + +class PlatformTypeType(Enum): + """Enumeration used to declare types of platform type. + + * U - Undefined + * PL - Platform/track at train station + * ST - Stop at bus or tram station + * GA - Terminal/Gate at airport + * PI - Pier if ship or ferry + * SL - Slot/parking space if bike or car + * FL - Floor in buildings or at footpath + * CI - Check-in/entrance + * CO - Check-out/exit + * X - No explicit type + * H - Hide platform information + """ + + U = auto() + "Undefined" + + PL = auto() + "Platform/track at train station" + + ST = auto() + "Stop at bus or tram station" + + GA = auto() + "Terminal/Gate at airport" + + PI = auto() + "Pier if ship or ferry" + + SL = auto() + "Slot/parking space if bike or car" + + FL = auto() + "Floor in buildings or at footpath" + + CI = auto() + "Check-in/entrance" + + CO = auto() + "Check-out/exit" + + X = auto() + "No explicit type" + + H = auto() + "Hide platform information" From 34953dd73938d5ed7ce05170a6d2ec71a527b685 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sat, 7 Sep 2024 20:21:52 +0200 Subject: [PATCH 2/5] Added Python 3.12 support --- pyproject.toml | 3 ++- tox.ini | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 41f7f72..ffaa568 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", ] @@ -44,7 +45,7 @@ speed = { file = "requirements/speed.txt" } where = ["src"] [tool.black] -target-version = ['py38', 'py39', 'py310', 'py311'] +target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] line-length = 94 [tool.isort] diff --git a/tox.ini b/tox.ini index b3d08ff..e35f504 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.8.0 -envlist = py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312 isolated_build = true [gh-actions] @@ -9,6 +9,7 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] setenv = @@ -21,4 +22,3 @@ deps = -r{toxinidir}/requirements/speed.txt commands = pytest --basetemp={envtmpdir} --cov=pyrmv --cov-report term-missing - From 0096581595597b9129ad236cdafc0effa08250d5 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 8 Sep 2024 00:51:21 +0200 Subject: [PATCH 3/5] Disabled unused async libraries --- requirements/dev.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 15ec5e0..5418d17 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -3,10 +3,10 @@ build==1.2.2 isort==5.13.2 mypy~=1.11.0 pylint==3.2.7 -pytest-asyncio~=0.24.0 +# pytest-asyncio~=0.24.0 pytest-cov~=5.0.0 pytest~=8.3.1 tox==4.18.0 twine~=5.1.0 -types-aiofiles~=24.1.0.20240626 +# types-aiofiles~=24.1.0.20240626 types-ujson~=5.10.0.20240515 From 34a601424bd27418f3d26a2f5b628cf20a0ef238 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 8 Sep 2024 01:27:58 +0200 Subject: [PATCH 4/5] Dependencies bumped and .gitignore updated --- .gitignore | 1 + requirements/_.txt | 2 +- requirements/dev.txt | 14 +++++++------- requirements/dist.txt | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 requirements/dist.txt diff --git a/.gitignore b/.gitignore index b34c603..1fab850 100644 --- a/.gitignore +++ b/.gitignore @@ -154,6 +154,7 @@ cython_debug/ # Custom +.mise.toml .vscode/ .venv_linux/ .venv_windows/ diff --git a/requirements/_.txt b/requirements/_.txt index 9f72bdf..317f56d 100644 --- a/requirements/_.txt +++ b/requirements/_.txt @@ -1,3 +1,3 @@ -requests~=2.32.0 +requests~=2.32.3 xmltodict~=0.13.0 isodate~=0.6.1 \ No newline at end of file diff --git a/requirements/dev.txt b/requirements/dev.txt index 5418d17..5cafd9f 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,12 +1,12 @@ black~=24.8.0 -build==1.2.2 isort==5.13.2 -mypy~=1.11.0 +mypy~=1.11.2 pylint==3.2.7 -# pytest-asyncio~=0.24.0 pytest-cov~=5.0.0 -pytest~=8.3.1 -tox==4.18.0 -twine~=5.1.0 -# types-aiofiles~=24.1.0.20240626 +pytest~=8.3.2 +tox==4.18.1 types-ujson~=5.10.0.20240515 + +# Disabled async libraries for now +# types-aiofiles~=24.1.0.20240626 +# pytest-asyncio~=0.24.0 \ No newline at end of file diff --git a/requirements/dist.txt b/requirements/dist.txt new file mode 100644 index 0000000..cf431e7 --- /dev/null +++ b/requirements/dist.txt @@ -0,0 +1,2 @@ +build==1.2.2 +twine~=5.1.1 From cbcfc8604fd19ed94a6a84bde387284af0987f61 Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 8 Sep 2024 01:28:18 +0200 Subject: [PATCH 5/5] Changed testing method for Client.him_search() --- tests/test_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 734bc4c..c1471df 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -20,9 +20,12 @@ def test_board_departure(api_client: Client, sample_stop_id: str): def test_him_search(api_client: Client): - assert isinstance( - api_client.him_search(time_end=datetime.now() + timedelta(days=10))[0], Message - ) + response = api_client.him_search(time_end=datetime.now() + timedelta(days=10)) + + if len(response) != 0: + assert isinstance(response[0], Message) + else: + assert isinstance(response, list) def test_journey_detail(api_client: Client, sample_journey_id: str):