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

Formatter: Unnecessary parentheses around return type annotations #9447

Closed
MichaReiser opened this issue Jan 9, 2024 · 1 comment · Fixed by #13381
Closed

Formatter: Unnecessary parentheses around return type annotations #9447

MichaReiser opened this issue Jan 9, 2024 · 1 comment · Fixed by #13381
Labels
bug Something isn't working formatter Related to the formatter

Comments

@MichaReiser
Copy link
Member

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
@MichaReiser MichaReiser added bug Something isn't working formatter Related to the formatter labels Jan 9, 2024
@MichaReiser MichaReiser added this to the Formatter: Stable milestone Jan 9, 2024
@icp1994
Copy link

icp1994 commented Jul 26, 2024

I know this is somewhat of an edge case, but any workaround (tweaks in settings) for this?

Off-topic: maybe issues from here could be moved to a new Formatter: Post Stable milestone for easier tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatter Related to the formatter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants