From 72baaaf86e484cce32a86248b7126b9b7e96ab3a Mon Sep 17 00:00:00 2001 From: Tobias Schmitt Date: Sun, 14 Jul 2024 23:39:17 +0200 Subject: [PATCH] fix: improvements --- cogs/weather.py | 11 +++++------ requirements.txt | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cogs/weather.py b/cogs/weather.py index f414706..5b13e21 100644 --- a/cogs/weather.py +++ b/cogs/weather.py @@ -9,7 +9,6 @@ from ezcord import codeblock from pyowm import OWM from pyowm.utils import timestamps -from pyowm.weatherapi25 import Weather as WeatherClass from translate import Translator load_dotenv() @@ -35,7 +34,7 @@ async def get_view( sunrise: str, sunset: str, forecast: bool = False, - original_weather: WeatherClass | None = None, + original_weather=None, ) -> discord.ui.View: if forecast: label = "Jetzt" @@ -51,7 +50,7 @@ async def get_view( async def get_weather_embed( - weather: WeatherClass, city: str, sunrise: str, sunset: str, three_hours: bool = False + weather, city: str, sunrise: str, sunset: str, three_hours: bool = False ) -> discord.Embed: temperaturen = weather.temperature("celsius") temp = round(int(temperaturen.get("temp"))) @@ -103,7 +102,7 @@ async def weather(self, ctx: ezcord.EzContext, city: str): observation = mgr.weather_at_place(city) except pyowm.commons.exceptions.NotFoundError: return await ctx.error(f"Die Stadt **{city}** konnte nicht gefunden werden.") - weather: WeatherClass = observation.weather + weather = observation.weather sunrise = discord.utils.format_dt(weather.sunrise_time(timeformat="date"), "T") sunset = discord.utils.format_dt(weather.sunset_time(timeformat="date"), "T") embed = await get_weather_embed(weather, city, sunrise, sunset) @@ -122,7 +121,7 @@ def __init__( label: str, sunrise: str, sunset: str, - weather: WeatherClass, + weather, style: discord.ButtonStyle | None = discord.ButtonStyle.primary, ): super().__init__(label=label, style=style, custom_id="forecast_button") @@ -137,7 +136,7 @@ async def callback(self, interaction: Interaction): three_hours = False else: prognose = mgr.forecast_at_place(self.city, "3h") - response: WeatherClass = prognose.get_weather_at(timestamps.next_three_hours()) + response = prognose.get_weather_at(timestamps.next_three_hours()) weather = response three_hours = True embed = await get_weather_embed( diff --git a/requirements.txt b/requirements.txt index 9781cdf..b08b5f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ ezcord python-dotenv pyowm translate +setuptools