-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Suggestion: use lowercase letters in hex literals #1692
Comments
See also recent #1514, asking for lowercase hexadecimal due to the similarity of |
I really can't recall anymore, and couldn't find a mention of this in our discussions either, but I'm sure there was discussion. |
ABB4AB8A isn't this enough to settle the issue? |
I'll gladly fix this if everyone agrees on it? :) |
I've heard no contrarian opinions so far |
I agree that lowercase is better in a vacuum. I'm not as sure if this change is worth the pain of changing Black's existing style. Every time we change Black's current style, that means people who use Black to format an existing codebase need to reformat their code, which pollutes their commit histories and might break open branches. So to decide whether to make a formatting change, we need to see if the gains from the formatting change outweigh the pains of changing existing formatting. We don't have a good framework for making that tradeoff, but it's worth thinking about. |
Sure, let's think about this. |
There we go - created a PR. if you do appreciate it, please label it with I would also argue, as a user, that the change is minor, and as we are using black to not really think about formatting, it will simply happen in the background i guess. Also if you want to be explicit in your formatting rules, then you should probably freeze the version of your formatter. This seems like a minor change, and not everyone has hex numbers in their source code. Your call :) Just happy that I could, hopefully, help. EDIT: I am not sure what |
I was the original advocate for upper-case numerals and based on my whining we decided to revert this change. The responsibility for the disruption is mine alone, I'm sorry to have wasted your time. Line of reasoning:
|
Maybe we can revisit this before we go "stable" one last time and if (and only if) we get a lot of the community behind this (maybe can do a survey or something) we could do a dedicated release for this case change. |
- It was reverted to not cause so much diff churn on millions of lines of code
- It was reverted to not cause so much diff churn on millions of lines of code - Fix primer config for projects that should now pass
Man, I hoped I would be a dedicated contributor. but that's all fine :) I do see your point @ambv and agree. |
* Made hex lower case * Refactored numeric formatting section * Redid some refactoring and removed bloat * Removed additions from test_requirements.txt * Primer now expects expected changes * Undid some refactoring * added to changelog * Update src/black/__init__.py Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com> Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com> Co-authored-by: Cooper Lees <me@cooperlees.com>
Reading the code, when I saw the commend saying
All letters used in the representation are normalized to lowercase
, I thought it also refers to hex letters. However, a few lines later, I was disappointed to seeChange hex literals to upper case.
.black/src/black/__init__.py
Lines 5158 to 5168 in 6284953
There's one practical issue with use of upper-case hex letters, though, and that's similarity between letter
B
and digit8
.I have seen bugs caused by this similarity in security-sensitive code, such as UTF-8/-16 decoders. Personally, I always used uppercase letters in hex numerals prior to that incident, because of the aesthetics of it; but, since then, have been switching to lowercase anywhere possible.
Maybe Black would consider switching to lowercase hex letters, as well?
The text was updated successfully, but these errors were encountered: