-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Colon inside a range gets a colon added to it #1413
Comments
This is documented in the README: https://github.com/psf/black/blob/master/README.md#slices |
But it would seem that this is not enforced consistently, eg: def a(code: str, pos: int):
x = code[pos : pos + 10] # Spaces here
y = code[pos:pos] # No spaces here |
We should probably expand that paragraph a bit in the docs. PEP8 recommends no spaces around |
Ah, this makes sense. I guess I'm just too used to flake8's syntax. I think it would be good to mention, in "installation and usage", a basic configuration for flake8 that aligns with black. Would you guys accept a PR that describes this? |
(I realise the individual settings are mentioned in different places, but I'm talking about a single-block copy-pasteable thing :) ) |
FWIW here's the relevant code that implements this behavior: Lines 1411 to 1413 in 45c98cf
I would turn off flake8 warnings related to subscripts (in fact, related to all code formatting). #1371 added an example flake8 config. If you think that needs tuning, feel free to open a PR :) BTW this is a duplicate of #889, #940, #1343, and possibly more. Thanks @hugovk for replying to all of them :) |
Oh, it has! Guess I have to read the updated README! Thanks, sorry for the noise! |
The colon before inside a range gets a space added to it:
input:
output
This seems to be the only scenario in which black adds a space before a colon, so I'm assuming it's a bug. Flake8 immediately complains since that's, well, wrong.
This doesn't seem to happen if
+ 10
is not there.Environment:
Does this bug also happen on master?:
Yes
The text was updated successfully, but these errors were encountered: