You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Concatenated list comprehensions should be put one-per-line rather than splitting within a comprehension.
Examples in the current Black style
matching_routes = [r for r in routes if r.get("dst") and ip in ipaddress.ip_network(r.get("dst"))] + [
r for r in routes if r.get("dst") == "" and r.get("family") == family
]
Desired style
matching_routes = (
[r for r in routes if r.get("dst") and ip in ipaddress.ip_network(r.get("dst"))] +
[r for r in routes if r.get("dst") == "" and r.get("family") == family]
)
Additional context
Currently, Black will reformat the desired style above into the current style shown above, which is a pretty clear loss for readability. Note that the above example was done with a custom line length limit of 120 but the same issue will come up with other line lengths.
The text was updated successfully, but these errors were encountered:
def foo():
matching_routes = [
r for r in routes if r.get("dst") and ip in ipaddress.ip_network(r.get("dst"))
] + [r for r in routes if r.get("dst") == "" and r.get("family") == family]
would be better as:
def foo():
matching_routes = (
[r for r in routes if r.get("dst") and ip in ipaddress.ip_network(r.get("dst"))] +
[r for r in routes if r.get("dst") == "" and r.get("family") == family]
)
I agree it looks better in these examples and I'd encourage you to make a PR trying to implement it, but style changes in Black often have effects in unexpected areas, and I'll have to see the changes from the PR before I can commit to making a style change.
Describe the style change
Concatenated list comprehensions should be put one-per-line rather than splitting within a comprehension.
Examples in the current Black style
Desired style
Additional context
Currently, Black will reformat the desired style above into the current style shown above, which is a pretty clear loss for readability. Note that the above example was done with a custom line length limit of 120 but the same issue will come up with other line lengths.
The text was updated successfully, but these errors were encountered: