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

Trailing parenthesized function return type comment becomes leading comment #13369

Closed
Tracked by #13371
MichaReiser opened this issue Sep 16, 2024 · 0 comments · Fixed by #13379
Closed
Tracked by #13371

Trailing parenthesized function return type comment becomes leading comment #13369

MichaReiser opened this issue Sep 16, 2024 · 0 comments · Fixed by #13379
Labels
bug Something isn't working formatter Related to the formatter

Comments

@MichaReiser
Copy link
Member

MichaReiser commented Sep 16, 2024

def foo(
    arg: (  # comment with non-return annotation
        int
        # comment with non-return annotation
    ),
):
    pass


def foo(
    arg: (  # comment with non-return annotation
        int
        | range
        | memoryview
        # comment with non-return annotation
    ),
):
    pass

def foo(arg: (
        int
        # only after
)):
    pass

Output

def foo(
    # comment with non-return annotation
    # comment with non-return annotation
    arg: (int),
):
    pass


def foo(
    # comment with non-return annotation
    # comment with non-return annotation
    arg: (int | range | memoryview),
):
    pass


def foo(
    # only after
    arg: (int),
):
    pass

Found by going through the tests in psf/black#4453

@MichaReiser MichaReiser added bug Something isn't working formatter Related to the formatter labels Sep 16, 2024
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.

1 participant