GH-121970: Use Ruff to check and format the docs tools#122018
Conversation
AlexWaygood
left a comment
There was a problem hiding this comment.
I'm generally in favour!
Sorry, something went wrong.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Me too! Note there's some overlap with #121241 which @AlexWaygood wanted to post about on Discourse first. I'm also fine with not doing so. |
Sorry, something went wrong.
Is that the right issue/PR? I don't see a mention of Ruff on it. |
Sorry, something went wrong.
|
I'm specifically nervous about enabling more aggressive linting on stdlib modules in |
Sorry, something went wrong.
AlexWaygood
left a comment
There was a problem hiding this comment.
I would personally go for quote-style = "preserve", and switch to quote-style = "double" in a followup, rather than going for quote-style = "single" (https://github.com/python/cpython/pull/122018/files#r1684185495). But I don't feel strongly. LGTM!
Sorry, something went wrong.
|
Thanks @AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, something went wrong.
|
Sorry, @AA-Turner, I could not cleanly backport this to |
Sorry, something went wrong.
|
Sorry, @AA-Turner, I could not cleanly backport this to |
Sorry, something went wrong.
|
Thanks @AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, something went wrong.
|
Thanks @AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
|
Sorry, @AA-Turner, I could not cleanly backport this to |
Sorry, something went wrong.
…ythonGH-122018) (cherry picked from commit 40855f3) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@gmail.com>
|
No problem :) |
Sorry, something went wrong.
|
I got a lint failure on a PR: As far as I know, the import block is OK according to PEP 8. When adding checks like this, could you also add some instructions to the devguide about how to deal with the warnings -- preferably without installing third-party tools I might not trust? |
Sorry, something went wrong.
|
@encukou, I'm sorry if we rushed this. Sorry that the error was inscrutable; thanks for flagging.
We already have documentation in the devguide noting that we have pre-commit checks set up, and giving some instructions about setting up pre-commit locally:
(I personally tend to avoid actually installing pre-commit hooks myself -- I usually run
Our CI is setup so that generally pre-commit will show you the changes it wants you to make to your PR as a diff when CI fails. In this case, it looks like that didn't happen for #121278. I'm not sure why that is, but anyway -- it's telling you that your imports aren't alphabetically sorted. You can find the documentation for the |
Sorry, something went wrong.
Thanks! I filed python/devguide#1360 to improve the set-up instructions. (If you don't do it yourself, is installing pre-commit as a commit hook the right thing to do?)
I don't understand why it is important to sort imports alphabetically. |
Sorry, something went wrong.
It's a thing that many people like to do. The advantage is that you don't have to run the linter manually; it automatically applies any autofixes as part of running I wasn't involved in the decision to add a section to the devguide telling people to setup commit hooks to run pre-commit.
It's not particularly important, but many people have decided that it's something they want to enforce as a matter of style. I personally like to enforce a consistent style of imports in this way in the projects I maintain, but I also wouldn't be distraught if we got rid of this rule.
PEP 8 is the style guide for the standard library, and we're not enforcing this rule on the standard library -- only internal tooling in the |
Sorry, something went wrong.
Same here on both counts. Alphabetical import sorting can be more useful, than for example, new imports being tacked onto the end:
|
Sorry, something went wrong.
But as a contributor to various projects, each of which expects or enforces a slightly different code style (and most of which expect me to format the code), I get the opposite of consistency. If alphabetical import sorting is useful, I do think it should be preferred for new code across the entire project. Then, it would be easier to accept that in some parts of the code we enforce some parts of the style guide. It worries me to see a maintainer that has things set up just right, slightly differently than what's in the docs, while others get an inscrutable error for what should be a simple contribution. Should we be worried about non-dogfooded devguide instructions? |
Sorry, something went wrong.
pyspecific#121970📚 Documentation preview 📚: https://cpython-previews--122018.org.readthedocs.build/