-
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
added whitespace in ranged sequence access #279
Comments
Thanks for your report. This stems from our implementation of PEP 8-compliant slicing (see #178). I'm not sure what to think about this example. It looks weird at first but if you accept that colon is now treated as a low-priority operator (if operands are complex), it makes sense. PEP 8 gives following examples as "Yes": ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
ham[lower + offset : upper + offset] |
@ambv thanks for the note, in that case flake8 is wrong as
|
Yes, E203 is not pep8 compliant. The readme mentions this, but maybe we
should emphasize these common issues in a more prominent place
…On Wed, 30 May 2018, 11:29 Ronny Pfannschmidt, ***@***.***> wrote:
@ambv <https://github.com/ambv> thanks for the note, in that casle flake8
is wrong
as
$ cat example.py
a = []
b = []
a[len(b) :]
$ flake8 example.py
example.py:3:9: E203 whitespace before ':'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#279 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEtG_gb1a_uKTmOQ5cfdZSBE6wm9TAks5t3mZ-gaJpZM4US2ZE>
.
|
Yes, @RonnyPfannschmidt, that warning was originally designed to avoid spaces before colons in defs, if statements, and so on. It's an unfortunate coincidence that it also covers slicing (and wrong!). |
Can you please prove your claim that this is wrong? The official Python tutorial doesn't use spaces for slicing. Is it because PEP8 says, "should have equal amounts on either side"? |
Here's our explanation in our docs:
https://github.com/psf/black/blob/master/docs/the_black_code_style.md#slices And here's the wording from PEP 8 our explanation is based off:
And here's an example PEP 8 explicitly says "yes" to: ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
ham[lower + offset : upper + offset] https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements (scroll after 3 bullet points and you should see it) See also: PyCQA/pycodestyle#373 |
from https://github.com/tox-dev/tox/pull/833/files/f30411399372e65016772b5da8c38cd39620ef1f#diff-4c32e51992275934b9b1b0b3838a021e
The text was updated successfully, but these errors were encountered: