-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
Apply some ruff rules #2353
base: main
Are you sure you want to change the base?
Apply some ruff rules #2353
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2353 +/- ##
=======================================
Coverage 99.16% 99.16%
=======================================
Files 40 40
Lines 3098 3098
Branches 680 680
=======================================
Hits 3072 3072
Misses 15 15
Partials 11 11 |
72307c0
to
895d54f
Compare
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.
@staticdev What do you think of adding ruff
to the linters? I don't really like making changes based on a linters output but then not adding the linter to CI to ensure the changes don't creep back in.
I don't see a problem we can add ruff linter. |
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.
It seems strange to apply ruff rules to a project that is not configured to follow ruff rules.
On a personal note, I view ruff as harmful to the Python ecosystem, as its paid developers cannibalize cumulative decades of others' work in a language that Python developers may not know how to contribute in. It's particularly galling that their homepage prominently features a quote from Timothy Crosley, who started and effectively abandoned isort itself sometime after ruff copied the project under a config option blatantly named isort
.
Anyway, I've left feedback on the PR. ruff introduced what appears to be an equivalently-unnecessary !s
in several f-strings that I suggest addressing.
@kurtmckee I am contributing also to open-source software since before Github exists, I feel you and share partly your opinion. But I have a long disclaimer, even being maintainer for isort, I am using ruff in many of my projects. I respect the diversity and competition of the projects and want them to thrive with isort, or ruff, or the next cool tool. This for me is kinda the beauty of open-source. Ruff is definetely fast but also feels immature and incomplete now. Astral for me is doing a good service, but needs some years maybe to catchup with all ambitious projects. Tldr: i think isort and ruff can coexist in piece. And we should make them help developers have a better life. |
Co-authored-by: Kurt McKee <[email protected]>
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.
This code change looks good to me.
I do not have merge rights so a maintainer would need to approve and merge. Should I add ruff to CI in this PR or in a separate PR? |
(By the way, @cclauss and @staticdev, I sometimes see you both pop up in other repos I interact with -- thanks for the work you both do!) |
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 @cclauss, I think this will improve our code readability. LGTM.
Thanks also @kurtmckee for the review.
@DanielNoord also good for you?
@cclauss I think this one already have a nice size. I would advice doing it in another one. |
Some optimizations for performance or readability.
%
ruff check --select=C4,E713,FLY,PERF401,PIE810,PLC0414,RUF005,RUF010,RUF021,SIM118,SIM201,UP004,UP033,W
https://docs.astral.sh/ruff/rules
I do not understand DeepSource's complaints that two functions have increased cyclomatic complexity when both ruff and flake8 agree that the cyclomatic complexity of these functions is unchanged.
%
ruff check --select=C901
# Results are the same onmain
and this branch.