-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hourly forecast #57
Conversation
Please format code with Black. |
This reverts commit e127e7c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I have a few minor comments. Please also add tests for the new method and update example.py
and README.md
files.
if not location_key: | ||
if not self._valid_coordinates(latitude, longitude): | ||
raise InvalidCoordinatesError("Your coordinates are invalid") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not remove this empty line.
@@ -119,15 +116,22 @@ def _parse_forecast(data: dict, to_remove: tuple) -> list: | |||
day[f"{temp}Min"] = day[temp]["Minimum"] | |||
day[f"{temp}Max"] = day[temp]["Maximum"] | |||
day.pop(temp) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not remove this empty line.
return False | ||
|
||
@staticmethod | ||
def _valid_api_key(api_key: str) -> bool: | ||
"""Return True if API key is valid.""" | ||
if isinstance(api_key, str) and len(api_key) == 32: | ||
return True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not remove this empty line.
@@ -146,6 +150,10 @@ async def _async_get_data(self, url: str) -> dict[str, Any]: | |||
data = await resp.json() | |||
if resp.headers["RateLimit-Remaining"].isdigit(): | |||
self._requests_remaining = int(resp.headers["RateLimit-Remaining"]) | |||
|
|||
# nasty hack to account for different data structure returned by hourly forecast API call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this. Please change return type for this method to Any
and use something like this:
if "hourly" in url:
return data
return data if isinstance(data, dict) else data[0]
@Geno1 Do you plan to continue this PR? |
Hi,
as stated in my last reaction, I’ve wasted more than enough time in reformatting the code for no reason. Feel free to take it, rewrite and reformat it as you like, or leave it. I no longer care.
Von: Maciej Bieniek
Gesendet: Sonntag, 21. August 2022 13:59
An: bieniu/accuweather
Cc: Geno1; Mention
Betreff: Re: [bieniu/accuweather] Add hourly forecast (PR #57)
@Geno1 Do you plan to continue this PR?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@Geno1 Thanks for your contributions 👍 |
* Add hourly forecast (#57) * Add API call for retrieving 12-hour hourly forecast data * Create main.py * Delete main.py Remove test code * Silence black * More black complaints "fixed" * Change data structure returned for hourly forecast * More complaints silenced * Remove unnecessary import * Remove unnecessary import * Revert "Remove unnecessary import" This reverts commit e127e7c. * Fix return type once more * Format * Fix _async_get_data return * Fix forecast * Update example and readme * Add tests * Update example and readme * Improve typing Co-authored-by: Geno1 <genone@genone.de>
Added a method to pull the hourly forecast data from Accuweather.