Skip to content
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

Generalize comment handling in flake8-comprehension fixes #4296

Open
dhruvmanila opened this issue May 9, 2023 · 0 comments
Open

Generalize comment handling in flake8-comprehension fixes #4296

dhruvmanila opened this issue May 9, 2023 · 0 comments
Labels
fixes Related to suggested fixes for violations

Comments

@dhruvmanila
Copy link
Member

I've provided a few examples but there will be a few more. As mentioned that whenever the parenthesis or brackets are being dropped, that's where this will happen. It seems to be happening in most of comprehension fixes.

I believe we should have a generalized way of resolving this.


C404

dict(
    # first comment
    [
        # second comment
        (i, i)
        for i in range(3)
    ]
)

{
    # first comment
    i: i
        for i in range(3)
}

C405

set(
    # some comment
    (1, 2)
)

{1, 2}

C406

dict(
    # first comment
    [
        # second comment
        (1, 2)
    ]
)

{
    # first comment
    1: 2
}

C409

tuple(
    # some comment
    [1, 2, 3, 4]
)

(1, 2, 3, 4)

C410

list(
    # some comment
    [1, 2, 3, 4]
)

[1, 2, 3, 4]

C411

list(
    # comment
    [i * i for i in x]
)

[i * i for i in x]

Originally posted by @dhruvmanila in #4099 (comment)

@dhruvmanila dhruvmanila changed the title Generalize comment handling in flake8-comprehension autofix Generalize comment handling in flake8-comprehension fixes May 9, 2023
@charliermarsh charliermarsh added the fixes Related to suggested fixes for violations label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations
Projects
None yet
Development

No branches or pull requests

2 participants