From 334980f208c7c5191f2ba64921a046438f8004e3 Mon Sep 17 00:00:00 2001 From: fwestenberg <47930023+fwestenberg@users.noreply.github.com> Date: Wed, 25 Sep 2024 09:30:04 +0200 Subject: [PATCH] Changed property typing and improved example --- setup.py | 2 +- stookwijzer/example.py | 24 +++++++++++++----------- stookwijzer/stookwijzerapi.py | 6 +++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index 7e4335e..c5349f7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name = 'stookwijzer', packages = ['stookwijzer'], - version = '1.4.9', + version = '1.4.10', license='MIT', description = 'Stookwijzer package', long_description_content_type="text/markdown", diff --git a/stookwijzer/example.py b/stookwijzer/example.py index 5cff8f8..137383c 100644 --- a/stookwijzer/example.py +++ b/stookwijzer/example.py @@ -4,23 +4,25 @@ import stookwijzerapi async def main(): - session = aiohttp.ClientSession() + session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) x, y = await stookwijzerapi.Stookwijzer.async_transform_coordinates(session, 52.123456, 6.123456) - print(x) - print(y) + print(f"x: {x}") + print(f"y: {y}") if x and y: sw = stookwijzerapi.Stookwijzer(session, x, y) await sw.async_update() - - print(sw.advice) - print(sw.alert) - print(sw.windspeed_bft) - print(sw.windspeed_ms) - print(sw.lki) - print(sw.forecast_advice) - print(sw.forecast_alert) + print() + print(f"advice: {sw.advice}") + print(f"alert: {sw.alert}") + print(f"windspeed bft: {sw.windspeed_bft}") + print(f"windspeed ms: {sw.windspeed_ms}") + print(f"lki: {sw.lki}") + print() + print(f"forecast_advice: {sw.forecast_advice}") + print() + print(f"forecast_alert: {sw.forecast_alert}") await session.close() diff --git a/stookwijzer/stookwijzerapi.py b/stookwijzer/stookwijzerapi.py index f637778..547f3b0 100644 --- a/stookwijzer/stookwijzerapi.py +++ b/stookwijzer/stookwijzerapi.py @@ -27,12 +27,12 @@ def advice(self) -> str | None: return self._advice @property - def alert(self) -> str | None: + def alert(self) -> bool | None: """Return the stookalert.""" return self._alert @property - def windspeed_bft(self) -> str | None: + def windspeed_bft(self) -> int | None: """Return the windspeed in bft.""" return self.get_property("wind_bft") @@ -43,7 +43,7 @@ def windspeed_ms(self) -> float | None: return round(float(windspeed), 1) if windspeed else windspeed @property - def lki(self) -> str | None: + def lki(self) -> int | None: """Return the lki.""" return self.get_property("lki")