Skip to content

single element tuples in yield expressions are not parenthesized #3851

@konstin

Description

@konstin

Describe the style change

Unlike other expression level single element tuples, single element tuples in yield expressions (e.g. yield 1,) are currently not parenthesized. This is inconsistent, they should also be parenthesized.

Examples in the current Black style

Input:

for a, in b:
    pass

c = d,


def e():
    yield f,
    return g,

Output:

for (a,) in b:
    pass

c = (d,)


def e():
    yield f,
    return (g,)

Desired style

for (a,) in b:
    pass

c = (d,)


def e():
    yield (f,) 
    return (g,)

Additional context

black 23.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions