Skip to content
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

Flake8 does not follow PEP 8 in slices #1356

Closed
levsa opened this issue Jul 9, 2021 · 2 comments
Closed

Flake8 does not follow PEP 8 in slices #1356

levsa opened this issue Jul 9, 2021 · 2 comments

Comments

@levsa
Copy link

levsa commented Jul 9, 2021

Example from PEP 8 (see "However, in a slice..."), partially run through black:

File flake_range.py:

ham = list(range(100))
lower = 3
upper = 8
offset = 1
step = 1
x = 4


def upper_fn(y: int) -> int:
    pass


step_fn = upper_fn

# Correct (after black):
ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:]
ham[lower:upper], ham[lower:upper:], ham[lower::step]
ham[lower + offset : upper + offset]
ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)]
ham[lower + offset : upper + offset]

# Wrong:
ham[lower + offset:upper + offset]
ham[1: 9], ham[1 :9], ham[1:9 :3]
ham[lower : : upper]
ham[ : upper]

# Wrong (after black):
ham[lower + offset : upper + offset]
ham[1:9], ham[1:9], ham[1:9:3]
ham[lower::upper]
ham[:upper]

Expected result:

/private/tmp/flake_range.py:24:7: E203 whitespace before ':'
/private/tmp/flake_range.py:24:17: E203 whitespace before ':'
/private/tmp/flake_range.py:24:30: E203 whitespace before ':'
/private/tmp/flake_range.py:25:10: E203 whitespace before ':'
/private/tmp/flake_range.py:25:12: E203 whitespace before ':'
/private/tmp/flake_range.py:26:5: E201 whitespace after '['

Actual result:

/private/tmp/flake_range.py:18:19: E203 whitespace before ':'
/private/tmp/flake_range.py:19:18: E203 whitespace before ':'
/private/tmp/flake_range.py:20:19: E203 whitespace before ':'
/private/tmp/flake_range.py:24:17: E203 whitespace before ':'
/private/tmp/flake_range.py:24:30: E203 whitespace before ':'
/private/tmp/flake_range.py:25:10: E203 whitespace before ':'
/private/tmp/flake_range.py:25:12: E203 whitespace before ':'
/private/tmp/flake_range.py:26:5: E201 whitespace after '['
/private/tmp/flake_range.py:29:19: E203 whitespace before ':'
@asottile
Copy link
Member

asottile commented Jul 9, 2021

please read the top of the issue template

@asottile asottile closed this as completed Jul 9, 2021
@simevo
Copy link

simevo commented Dec 17, 2021

the issue is tracked in pycodestyle here: PyCQA/pycodestyle#373

@PyCQA PyCQA locked as off-topic and limited conversation to collaborators Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants