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
Feature request: Option to use lowercase hex literals #10432
Comments
If I understand correctly, this is about formatting hex number literals like My preference would be to change the default to lowercase to make it consistent with hex formatting in strings. However, from reading through Black's issues and discussions on the string hex formatting PRs, I understand that Black changed the preferred casing for hex number literals multiple times and that it's unlikely that they'll change it again in the future. I don't know if I want to deviate from Black's default, considering that the benefits are marginal. That means that supporting lowercase hex formatting most likely requires adding a new formatter option. I'm not opposed to this, but we need to make a holistic decision if we want to support formatting-related options or keep Black's opinionated stance to have no-formatting-related settings (or very limited). |
Yeah, it's the number literals I'm interested in. As for whether it's actually worth it, I guess I'll leave that to everyone else to decide :) |
To me this kind of configuration is great. It shouldn't affect other formatting and it allows to adopt ruff formatting on an existing codebase that uses either style. I would also like to propose three values for this kind of config:
The last option let's the programmer choose case and don't modify it with the formatter - this should make the formatter faster 🐎 |
Piggybacking here a bit, but I was quite surprised when "Ruff format" changed the content of a hex string 1, and perplexed that the preference for string and number literal is different. "don't touch" or "off" option is also great to introduce to existing code bases. Footnotes
|
For a brief time window,
black
had this feature, before it was reverted psf/black#1692I'm a big fan of lowercase hex literals, for most of the practical reasons outlined in the above issue, and also for purely aesthetic reasons - uppercase feels shouty.
If I had my way I'd make lowercase the default, but failing that it'd be great to have a configuration option.
The text was updated successfully, but these errors were encountered: