-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
E203 fix should leave equal amounts of space on either side of a slice operator #7259
Comments
Our behavior is consistent with pycodestyle, but I am inclined to support this (though it's low priority). |
charliermarsh
added
rule
Implementing or modifying a lint rule
accepted
Ready for implementation
labels
Sep 11, 2023
It's also inconsistent with black, which puts spaces on both sides. |
I think this is a duplicate of #6861, but I'm happy to see it's considered/accepted now. 😃 |
Gonna look at fixing this today. |
charliermarsh
added a commit
that referenced
this issue
Nov 13, 2023
…ation` (`E203`) (#8654) ## Summary This PR makes `whitespace-before-punctuation` (`E203`) compatible with the formatter by relaxing the rule a bit, as compared to the pycodestyle implementation. It's also more consistent with PEP 8, which says: > However, in a slice the colon acts like a binary operator, and should have equal amounts on either side (treating it as the operator with the lowest priority). Closes #7259. Closes #8642. ## Test Plan `cargo test`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ruff --fix --select E203 bug.py
(v0.0.287) giveswhich is discouraged by PEP 8:
https://peps.python.org/pep-0008/#pet-peeves
So,
ham[lower + offset: upper + offset]
is incorrect. I would argue thatham[lower + offset : upper + offset]
(which is whatblack
outputs) should not be flagged byE203
; and if so, both spaces should be removed (but I still argue to remove none at all).The text was updated successfully, but these errors were encountered: