Skip to content

Commit

Permalink
Changed property typing and improved example
Browse files Browse the repository at this point in the history
  • Loading branch information
fwestenberg committed Sep 25, 2024
1 parent f1cbcff commit 334980f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 13 additions & 11 deletions stookwijzer/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions stookwijzer/stookwijzerapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")

Expand Down

0 comments on commit 334980f

Please sign in to comment.