Skip to content

Use fahrenheit when units are imperial in weather-api-widget - #487

Open
samschmalz wants to merge 2 commits into
streetturtle:masterfrom
samschmalz:weather_temp_f
Open

Use fahrenheit when units are imperial in weather-api-widget#487
samschmalz wants to merge 2 commits into
streetturtle:masterfrom
samschmalz:weather_temp_f

Conversation

@samschmalz

Copy link
Copy Markdown

I didn't see a good way to make a single check for units and set a single temperature variable for each type (temp, feelslike, and forecast min/max), since forecast use a loop to set multiple days in advance. Instead, each location that displays a temperature uses an anonymous function as a ternary operator to determine which to use.

I didn't see a good way to make a single check for units and set a
single temperature variable for each type (temp, feelslike, and forecast
min/max), since forecast use a loop to set multiple days in advance.
Instead, each location that displays a temperature uses an anonymous
function as a ternary operator to determine which to use.
@samschmalz
samschmalz requested a review from Ryuno-Ki as a code owner December 21, 2025 02:21

@Ryuno-Ki Ryuno-Ki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good first iteration. Would you be willing to test a PR if I happen to find the time to polish this?

Comment thread weather-api-widget/weather.lua Outdated
@@ -605,7 +605,7 @@ local function worker(user_args)

widget:set_image(ICONS_DIR .. icon_map[result.current.condition.code] .. day_night_extension .. icons_extension)
-- TODO: if units isn't "metric", read temp_f instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind removing comments like these?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can filter those out, I forgot to delete them from whenever they got put in. It looks like I need to break up those lines I added so they pass Luacheck as well, so I'll work on those as well before re-submitting.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Luacheck is meant to help with a more robust codebase. I figured to have it run before taking another look.
I am myself guilty of submitting failing code so don't sweat it.

@Ryuno-Ki Ryuno-Ki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks way nicer. Did you use a tool to handle the formatting?

Comment thread weather-api-widget/weather.lua Outdated
-- zh_cmn, mr, pl, pt, pa, ro, ru, sr, si, sk, es, sv, ta, te, tr, uk, ur, vi,
-- zh_wuu, zh_hsn, zh_yue, zu

-- default language is ENglish

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick (likely fixed by me): English with lowercase N

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally used Neovim, which I have set up with kickstart.nvim so it automatically formats code. However, I realized that doing so also touched almost every other line in the file with an invisible change I can't see (probably whitespace). I'd rather not do that because it obscures meaningful changes, so I had to revert and make the formatting changes manually. I did screw up my local git repo in the process, hence the force-push.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, a fellow NeoVim developer 🧡

An extraneous TODO was left behind after the previous commit, it has
been removed for clarity.

Several lines were too long to pass Luacheck, so they have been broken
up into multi-line statements so they meet style guidelines.

@Ryuno-Ki Ryuno-Ki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@samschmalz

Copy link
Copy Markdown
Author

Would you like me to fix the additional whitespace at the end of the listed lines, or would you prefer that I don't generate another commit to be reviewed? I'm okay with either option, but I also want to respect your time.

@Ryuno-Ki

Copy link
Copy Markdown
Collaborator

Please make the luacheck happy.

The formatting via kickstart.vim should happen in another PR if you have the energy still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants