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

Ruff format always splits single positional-only argument list across two lines #9074

Closed
drhagen opened this issue Dec 9, 2023 · 2 comments · Fixed by #9076
Closed

Ruff format always splits single positional-only argument list across two lines #9074

drhagen opened this issue Dec 9, 2023 · 2 comments · Fixed by #9076
Assignees
Labels
bug Something isn't working formatter Related to the formatter

Comments

@drhagen
Copy link

drhagen commented Dec 9, 2023

Black keeps this code as is:

def some_function(
    string: str, /
) -> ReallyReallyReallyReallyReallyReallyReallyReallyLongName:
    pass

But Ruff 0.1.7 forces the argument list to be split across lines.

def some_function(
    string: str,
    /,
) -> ReallyReallyReallyReallyReallyReallyReallyReallyLongName:
    pass

I would also consider Black's behavior to be more desirable here. This is a regression from Ruff 0.1.6. I suspect that this was caused by #8921, where it would be easy to think this function has one argument. Semantically, it does, while syntactically, it has two.

@charliermarsh
Copy link
Member

Interesting, that makes sense... Thanks for reporting!

@charliermarsh charliermarsh added bug Something isn't working formatter Related to the formatter labels Dec 9, 2023
@charliermarsh
Copy link
Member

Should be straightforward to fix. I appreciate you finding + linking back to the relevant PR.

@charliermarsh charliermarsh self-assigned this Dec 9, 2023
charliermarsh added a commit that referenced this issue Dec 9, 2023
…9076)

## Summary

In #8921, we changed our parameter
formatting behavior to add a trailing comma whenever a single-argument
function breaks. This introduced a deviation in the case that a function
contains a single argument, but _also_ includes a positional-only or
keyword-only separator.

Closes #9074.
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.

2 participants