Comments (6)
I'm 0.25 on this. Sometimes I like to see an additional set of parens for expressions in slices. Like:
whitespace = orig_line[:(-len(line))]
from blue.
I think that's fine. Let's close this one as "won't fix".
from blue.
Having looked through a bunch of diffs in the last hour, I've actually come around to Black's formatting here. The added space doesn't hurt.
from blue.
I can live with it, but it goes against PEP 8, IMHO:
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). In an extended slice, both colons must have the same amount of spacing applied. Exception: when a slice parameter is omitted, the space is omitted:
from blue.
Personally, I don't think it makes sense because this rule is inconsistent in that it causes spacing to change purely based on the type of expression (expressions are not treated uniformly).
Ie. Each of the following would be a consistent formatting rule:
foo[: bar_len]
andfoo[: len(bar)]
foo[:bar_len]
andfoo[:len(bar)]
.
But not how it does it right now which is:
foo[:bar_len]
andfoo[: len(bar)]
.
from blue.
Addressing my previous comment -- I realize now that the addition of parens is impossible given Black's constraints. Adding parens would modify the AST which Black forbids to prevent changing semantics.
@warsaw having read the PEP 8 section you quote, I don't see what part black violates here.
from blue.
Related Issues (20)
- [docs request] Examples of pyproject.toml and setup.cfg
- [Question] Active? HOT 2
- 0x and 0b case
- Coverage requirement fails
- Exclude not workin pyproject.toml
- error: cannot format main.py: Cannot parse: 66:21 HOT 1
- blue is incompatible with flake8 v5 HOT 9
- Unable to run Blue formatting HOT 4
- Don't expand brackets
- How to properly use Blue in GitHub Actions? HOT 1
- https://iblueit.dev/ is broken due to missing resources HOT 1
- Don't bind specific versions of `black`, monkey patch methods on `ast` level
- Continuation lines defined by extra indentation HOT 1
- Comply with PEP-8 for indentation of parameters in function definition HOT 3
- leave function-scope imports alone
- [docs request] Adding example pre-commit config to README
- Is this repository still active? The last update was 9 month ago HOT 4
- Doc: how to use blue with vscode? HOT 1
- Vim Plugin for blue HOT 5
- blue changes `%autoreload 2` in jupyter ntoebooks to random hex
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blue.