Skip to content

MAINT: Use double quotes (ruff rule Q) (only on .pyi files) #29548

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

Merged
merged 1 commit into from
Aug 14, 2025

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Aug 12, 2025

Double-quotes came up in a review: #29531 (comment)

If it's a preferred style, then I'd suggest it be automated

The only manual change I did here was to add Q to ruff.toml, everything else was just spin lint --fix

@MarcoGorelli MarcoGorelli changed the title MAINT: Use double quotes MAINT: Use double quotes (ruff rule Q) Aug 12, 2025
@mattip
Copy link
Member

mattip commented Aug 12, 2025

I prefer to play loose and free with either single- or double- quotes, but will play along if that is the community decision. It seems a bit disruptive to reformat everything though.

@jorenham
Copy link
Member

I'm all for enforcing this, but I can imagine that this 348 file diff could cause merge conflicts in many of the open PR's. So maybe we can limit this to e.g. .pyi or certain directories for now?

@MarcoGorelli MarcoGorelli changed the title MAINT: Use double quotes (ruff rule Q) MAINT: Use double quotes (ruff rule Q) (only on .pyi files) Aug 12, 2025
@MarcoGorelli
Copy link
Member Author

Sure, point taken, thanks - I've updated so it only applies to the .pyi files

@jorenham
Copy link
Member

I prefer to play loose and free with either single- or double- quotes

Out of curiosity; any particular reason for that?

@mattip
Copy link
Member

mattip commented Aug 12, 2025

Out of curiosity; any particular reason for that?

Double quotes are harder to type (two key presses) and somehow visually heavier and less appealing. So I usually use single quotes when it is a single word or character and double quotes when I truly want to make a statement.

@jorenham
Copy link
Member

jorenham commented Aug 12, 2025

Double quotes are harder to type (two key presses) and somehow visually heavier and less appealing. So I usually use single quotes when it is a single word or character and double quotes when I truly want to make a statement.

Yea I guess that makes sense. I'm also fine with using ' quotes everywhere. I suppose that enforcing one or the other is more about consistency, which can help reduce diff sizes, and avoids you from having to think about which one to use. So theoretically it doesn't matter which one we choose.

But note that the " choice is a lot more common (in my experience), probably because of black. So for those used to the black style (like me), the chance of accidentally using the wrong quotes is higher if we go with the less common ', which could lead to more CI usage. But who knows, perhaps that won't even be noticeable in practice 🤷🏻.

@charris
Copy link
Member

charris commented Aug 12, 2025

I have a slight preference for single quotes, but have been trying to move to double quotes because of Black. That said, it is easy enough to run ruff to fix things up.

@MarcoGorelli
Copy link
Member Author

it is easy enough to run ruff to fix things up

Yes, every project I contribute to has some expectation that you'll run make lint or spin lint or pre-commit run -a or some other command that does these automated things.

In other projects I just type single quotes (as @mattip observed, they're easier to type) and then let the auto-formatter sort them out according to the project's preferences

I'd appreciate it if this rule could at least be enabled for the stubs anyway, so that quotes can be consistent and neither reviewers nor contributors need think about them 🙏

@seberg
Copy link
Member

seberg commented Aug 14, 2025

Seems like we can just put this in? FWIW, would be nice to add the ruff rule, but not usre how easy it is just for the stubs.
(I don't mind just doing more/full auto-formatting, we break all PRs once of course, although you could probably ruff --fix and then merge most.)

@MarcoGorelli
Copy link
Member Author

Thanks!

but not usre how easy it is just for the stubs.

That's what this PR does, it enables the rule just for the stubs 😄 Check the changes to ruff.toml

@jorenham jorenham merged commit 8b89d0f into numpy:main Aug 14, 2025
79 checks passed
@jorenham
Copy link
Member

And in it goes; thanks Marco :)

@seberg
Copy link
Member

seberg commented Aug 15, 2025

Hah sorrysomehow I looked and missed the toml changes...

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

Successfully merging this pull request may close these issues.

5 participants