-
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
A comma should only be considered magical if followed by a newline #2354
Comments
Eg I think: x = {'a':42}
y = {'a':42,}
z = {'a':42,
} After x = {'a':42}
y = {'a':42}
z = {
'a':42,
} Is more understandable behaviour for black |
Or more specifically any whitespace including newlines before any other character |
This actually seems pretty reasonable, although I haven't really thought it through carefully. |
I just found a counter-example: self.lifespan_context = _wrap_gen_lifespan_context(
lifespan, # type: ignore[arg-type]
) |
so I think a narrower definition is to define a comma followed by a paren, bracket or brace as non-magical |
eg: # magic:
self.lifespan_context = _wrap_gen_lifespan_context(
lifespan, # type: ignore[arg-type]
) # magic:
self.lifespan_context = _wrap_gen_lifespan_context(
lifespan, # type: ignore[arg-type]) # maybe not magic:
self.lifespan_context = _wrap_gen_lifespan_context(
lifespan, ) # probably not magic:
self.lifespan_context = _wrap_gen_lifespan_context(
lifespan,) # not magic:
self.lifespan_context = _wrap_gen_lifespan_context(lifespan, ) # not magic:
self.lifespan_context = _wrap_gen_lifespan_context(lifespan,) |
It should be easy for humans to simulate Black's formatting, and I think this proposal crosses a complexity boundary. The magic trailing comma is already pretty magical and paying even more attention to existing formatting introduces more implementation complexity. |
I think there's something here. A comma should only be considered magical if followed by a newline
Originally posted by @graingert in #2353 (comment)
The text was updated successfully, but these errors were encountered: