-
-
Notifications
You must be signed in to change notification settings - Fork 696
Fix and enable more ruff rules #41166
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
base: develop
Are you sure you want to change the base?
Conversation
.github/workflows/lint.yml
Outdated
| run: | | ||
| uv run --frozen --only-group lint -- ruff check --output-format github --ignore E402,E721,E731,E741,E742,E743,F401,F402,F403,F405,F821,F841,I001,PLC0206,PLC0208,PLC1802,PLC2401,PLC3002,PLC0415,PLE0302,PLR0124,PLR0402,PLR0911,PLR0912,PLR0913,PLR0915,PLR1704,PLR1711,PLR1714,PLR1716,PLR1733,PLR1736,PLR2004,PLR5501,PLW0120,PLW0211,PLW0602,PLW0603,PLW0642,PLW1508,PLW1510,PLW1641,PLW2901,PLW3301 | ||
| uv run --frozen --only-group lint -- ruff check --output-format github --preview --select E111,E115,E21,E221,E222,E225,E227,E228,E25,E271,E272,E275,E302,E303,E305,E306,E401,E502,E701,E702,E703,E71,W291,W293,W391,W605,TC,UP006 src/sage/ | ||
| uv run --frozen --only-group lint -- ruff check --output-format github --ignore E402,E721,E731,E741,E742,E743,F401,F402,F403,F405,F821,F841,I001,PLC0206,PLC0208,PLC1802,PLC2401,PLC3002,PLC0415,PLE0302,PLR0124,PLR0402,PLR0911,PLR0912,PLR0913,PLR0915,PLR1704,PLR1711,PLR1714,PLR1716,PLR1733,PLR1736,PLR2004,PLR5501,PLW0120,PLW0211,PLW0602,PLW0603,PLW0642,PLW1508,PLW1510,PLW1641,PLW2901,PLW3301,UP |
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.
Disabling UP here because this command checks build/sage_bootstrap. I don't know what the purpose of that folder is, but the README in it says it needs to support Python 2.6 (surely that can't be right...) and when I tried running the ruff fixer on that folder things broke.
@tobiasdiez Do you know what that folder is for or why this workflow runs ruff twice?
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's the Python interface for the sage-packages and it is called by some of the shell scripts in bin, which themselves are invoked during bootstrap. Since sage-the-distro officially supports bootstrapping itself on very old Python's, the 2.6 requirement sounds plausible to me.
I think we should just hide that folder from ruff.
For the two commands, I think the difference is the --preview flag, or not?
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 think we should just hide that folder from ruff.
Done
For the two commands, I think the difference is the
--previewflag, or not?
There is more than that. The first one has --ignore rules, the second one has --select rules. The second one runs on src/sage/ and the first runs on the entire repo (I've now changed it to run on src/ to address your other comment).
|
Documentation preview for this PR (built with commit ef6a1ae; changes) is ready! 🎉 |
|
Running @tobiasdiez Do you want me to disable |
|
I think the test failures for |
Fix and enable RUF013, RUF036, UP004, UP008, UP010, UP015, UP022, UP034, and UP035.
Perhaps the most important of these is RUF013, which fixes implicit
Optionalin type annotations, as this is prohibited by PEP484. I also sorted the imports in the files that were changed in the process of fixing these rules.📝 Checklist
⌛ Dependencies