-
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
Weird line break of expression in list when comments are present #2593
Labels
T: style
What do we want Blackened code to look like?
Comments
Same here with method chains Without comments self.records = (
pd.read_csv(config.data.dataset_path, nrows=config.data.n_records)
.dropna(subset=[self.filepath_column, *config.targets])
.reset_index(drop=True)
) With comments (2 methods in one line for some reason) self.records = (
pd.read_csv(config.data.dataset_path, nrows=config.data.n_records)
# Drop records without ********************
.dropna(subset=[self.filepath_column, *config.targets]).reset_index(
drop=True
)
) Desired self.records = (
pd.read_csv(config.data.dataset_path, nrows=config.data.n_records)
# Drop records without ********************
.dropna(subset=[self.filepath_column, *config.targets])
.reset_index(drop=True)
) black 20.8b1, default config |
Same here as well, using input: [
# A
B == C
] output: [
# A
B
== C
] It gives something pretty weird to read. Anyhow, if it may help (but still not ideal), you can use parentheses as a workaround: [
# A
(B == C)
] output: [
# A
(B == C)
] |
is this the same problem?: input is async def __aexit__(self, exc_type, exc_value, traceback):
await self._close(
# if we're handling an exception, we assume that it's more
# important to deliver that exception than shutdown gracefully.
fast=exc_type is not None
) output is async def __aexit__(self, exc_type, exc_value, traceback):
await self._close(
# if we're handling an exception, we assume that it's more
# important to deliver that exception than shutdown gracefully.
fast=exc_type
is not None
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the style change
When a list contains a comment and a single expression (in that order), the expression seems to be broken into multiple lines regardless of length.
Surely short expressions should be kept on one line regardless of surrounding context?
Examples in the current Black style
Desired style
Additional context
Tested with black version
21.10b0
The text was updated successfully, but these errors were encountered: