Skip to content

Formatter: Unnecessary parentheses around return type annotations #9447

Closed
@MichaReiser

Description

@MichaReiser

Ruff adds unnecessary parentheses around return type annotations that are either:

  • guaranteed to break like multiline strings
  • Come with their own set of parentheses
def test() -> """test
""": pass

def test() -> [aaa, bbbb,]: pass

def test() -> lists(a, b,): pass

Ruff

def test() -> (
    """test
"""
):
    pass


def test() -> ([
    aaa,
    bbbb,
]):
    pass


def test() -> (
    lists(
        a,
        b,
    )
):
    pass

Black

def test() -> """test
""":
    pass


def test() -> [
    aaa,
    bbbb,
]:
    pass


def test() -> lists(
    a,
    b,
):
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingformatterRelated to the formatter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions