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
Return detailed forecast values in implied metric units #78
Return detailed forecast values in implied metric units #78
Conversation
…to detailed-forecast-units
Use Detail enum to include raw properties
I like having it cleaner this way, thanks! There are several other changes too so I need to review this next. I didn't fully appreciate that the detailed forecast was also in metric units. It is awkward that the default values for the simple hourly and daily forecasts are in imperial units. |
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.
Looking good to me. Minor comment. Should we be testing the code with mypy
, in a separate PR, now that you've been adding typing? Thanks for this BTW.
I've just learned that the feature flags:
will make the simple forecasts return the temperature and wind speed in a consistent SI format as the observations and detailed forecast. The textual forecast will remain in imperial (unless you also ask for |
Since the NWS only covers the US, most pynws users will likely be in the US. So using imperial units for everything might make sense. However, that is a significant breaking change. Having a default unit system setting on the Nws base class would be less impactful. It could be set to metric, imperial or unset (which would retain existing behavior). Thoughts? |
I've been using pylint which is already in the pynws checkin actions, but I've just been dabbling. I'll take a look at mypy when I have some time. |
The feature flags I'm talking about not only give you SI units, but gives the same structure, i.e a dict with value and unit. This alignment is also very useful. I'm not sure how "in production" these features are, so it is probably best to just keep watching it. It isn't worth having a breaking change for a feature that isn't promised to be in the API.
I agree. This needs more continued thought to get right. Trying to aim for consistency first is a good first goal, which this PR provides. |
pynws/units.py
Outdated
return converter | ||
|
||
|
||
def convert_unit(unit_code: str, value: Any): |
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.
Can we type value
and the return? I think we need to use this https://stackoverflow.com/a/69383462/11423283
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.
Can we type
value
and the return? I think we need to use this https://stackoverflow.com/a/69383462/11423283
Fixed
I played with mypy a few minutes last night and found lots of issues. I'll fix the ones caused by this PR. |
Python 3.7 and 3.8 support for type hinting is limited. The current build errors are due to this. I'm not sure that there's a compatible syntax that will work for 3.7 or 3.8. If not, we'll either need to revert the type hints or change the minimum version to 3.9.
|
Have you tried |
That works. Thanks! |
I reworked my previous PR to standardize detailed forecast values as implied metric values