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

black mishandles magic comma in context managers #3137

Open
graingert opened this issue Jun 24, 2022 · 2 comments
Open

black mishandles magic comma in context managers #3137

graingert opened this issue Jun 24, 2022 · 2 comments
Labels
F: trailing comma Full of magic T: bug Something isn't working

Comments

@graingert
Copy link
Contributor

Black fa6caa

Playground link

Options

--line-length=88
--safe

Input

@gen_test()
async def test_eq():
    async with Cluster(
        asynchronous=True,
        name="A",
    ) as clusterA, Cluster(
        asynchronous=True,
        name="A2",
    ) as clusterA2, Cluster(
        asynchronous=True,
        name="B",
    ) as clusterB:
        assert clusterA != "A"
        assert not (clusterA == "A")
        assert clusterA == clusterA
        assert not (clusterA != clusterA)
        assert clusterA != clusterA2
        assert not (clusterA == clusterA2)
        assert clusterA != clusterB
        assert not (clusterA == clusterB)

Output

@gen_test()
async def test_eq():
    async with Cluster(asynchronous=True, name="A",) as clusterA, Cluster(
        asynchronous=True,
        name="A2",
    ) as clusterA2, Cluster(
        asynchronous=True,
        name="B",
    ) as clusterB:
        assert clusterA != "A"
        assert not (clusterA == "A")
        assert clusterA == clusterA
        assert not (clusterA != clusterA)
        assert clusterA != clusterA2
        assert not (clusterA == clusterA2)
        assert clusterA != clusterB
        assert not (clusterA == clusterB)

Expected

idempotency

@graingert
Copy link
Contributor Author

I think black should emit an internal error if it emits a ,) outside a tuple, or a ,] or ,}

@JelleZijlstra JelleZijlstra added the F: trailing comma Full of magic label Jun 24, 2022
@JelleZijlstra
Copy link
Collaborator

Feels similar to #1671.

@ichard26 ichard26 added the T: bug Something isn't working label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: trailing comma Full of magic T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants