-
Notifications
You must be signed in to change notification settings - Fork 49
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
Ruff: smaller steps #364
Ruff: smaller steps #364
Conversation
@rcomer Thanks for this 🚀 I was waiting for SciTools/iris#5254 to conclude, then reopen SciTools/iris#353, but totally happy to replace it with this 👍 |
9b32f11
to
4e7683a
Compare
Rebased, updated the ruff version and replaced black with ruff's formatter. Swapping black for ruff's formatter only affects one line, shown in the most recent commit. We now have more failures and fewer autofixes from main ruff. I think because some fixes that were previously done automatically are now marked "unsafe" so we would need to manually opt in (see https://astral.sh/blog/ruff-v0.1.0#respecting-fix-safety). |
I applied the "unsafe" fixes but then tweaked a few that didn't look quite right to me. Also tidied up the remaining errors so I think this is now ready for review. Unlike most of my branches, the individual commits here may be meaningful enough to review individually. |
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.
Looks like a good improvement to me.
(I doubt I will get a chance to follow-up, but hopefully my review moves the PR forwards 😉
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 @pelson - great to hear from you again! I will follow up more when I am back on my work machine.
New commit dismissed an approving review. Not seen that before 😕 |
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.
Since it's taken us a while to get to this PR, the versions here have become a bit stale. We should have time to focus on cf-units this week, so if you respin this PR with newer versions and resolve merge conflicts, we ought to be able to get this reviewed and merged in.
Hi @stephenworsley thanks for taking a look. I’m afraid I do not know if I will get to this this week. If anyone wants to push to my branch to get it through sooner, please do. |
* main: [pre-commit.ci] pre-commit autoupdate (SciTools#425) Adopt cython3 (require >=3) (SciTools#460) Add repo-review (SciTools#456) Fully support Python 3.12 (SciTools#461) Bump peter-evans/create-pull-request from 6.0.4 to 7.0.5 (SciTools#459) Fix for bad git path in GHA macos instances. (SciTools#464) test macos wheels (SciTools#458) Bump pypa/cibuildwheel from 2.20.0 to 2.21.1 (SciTools#457) Fixes for CI wheels (SciTools#455) Dependabot check weekly. (SciTools#439) # Conflicts: # .pre-commit-config.yaml # cf_units/tests/test_coding_standards.py # pyproject.toml
for more information, see https://pre-commit.ci
* rcomer/ruff: [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* rcomer/ruff: [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* rcomer/ruff: [pre-commit.ci] auto fixes from pre-commit.com hooks # Conflicts: # cf_units/tests/test_coding_standards.py
for more information, see https://pre-commit.ci
* rcomer/ruff: [pre-commit.ci] auto fixes from pre-commit.com hooks
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'm happy with your changes @stephenworsley, I'll leave you to check the rest of the PR.
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 believe this should be good now.
* main: [DOCS] Update docstring for date2num (module function) (SciTools#483) Modernise setup scripts (SciTools#484) Make antlr optional (SciTools#423) Ruff: smaller steps (SciTools#364) Updated docstring for num2date. (SciTools#467) updated conda lock files (SciTools#479) Revert to 00:03 Mondays for lockfile updates. (SciTools#480) New trigger time for GMT. (SciTools#478) Check lockfile updates @ 3pm daily (temporary for testing). (SciTools#477) Fixlocks (SciTools#470) # Conflicts: # pyproject.toml # requirements/cf-units.yml # requirements/locks/py310-lock-linux-64.txt # requirements/locks/py310-lock-osx-64.txt # requirements/locks/py310-lock-win-64.txt # requirements/locks/py311-lock-linux-64.txt # requirements/locks/py311-lock-osx-64.txt # requirements/locks/py311-lock-win-64.txt # requirements/locks/py312-lock-linux-64.txt # requirements/locks/py312-lock-osx-64.txt # requirements/locks/py312-lock-win-64.txt
🚀 Pull Request
Description
SciTools/iris#353 proposed introducing ruff to cf-units for linting, but also changed some style choices (max line length and import sort order). IMO this made it difficult to spot what effect ruff was having on the code. This PR breaks it down so hopefully it's easier to see what's going on:
dict(...)
to{...}
- maybe for speed?if thing == None
toif thing is None
- I'm surprisedflake8
didn't catch that oneCI will fail with remaining problems that ruff found: