Skip to content

Line break added in list comprehension separates variable from its expression #4514

Closed

Description

@funkybob

Black c47255

Playground link

Options

--line-length=88
--safe

Input

x = [
    t
    for t in y
    if t not in {
        LongNameOne,
        LongNameTwo,
        LongNameThree,
    }
]

Output

x = [
    t
    for t in y
    if t
    not in {
        LongNameOne,
        LongNameTwo,
        LongNameThree,
    }
]

Expected

x = [
    t
    for t in y
    if t not in {
        LongNameOne,
        LongNameTwo,
        LongNameThree,
    }
]

By moving the not in onto its own line it separates the variable from the expression it's a part of, breaking visual parsing.

Activity

  1. MrunaliniPachpute commented on Dec 11, 2024

    @MrunaliniPachpute

    Hi @funkybob, can I work on this issue to address the concern with the not in operator?

  2. funkybob commented on Dec 11, 2024

    @funkybob
    Author

    Hi @MrunaliniPachpute ... I'm in no position to control who works on this issue, but I wholly welcome you trying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions