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 undocumented deviation: add comma after single argument definition #7323

Closed
JonathanPlasse opened this issue Sep 12, 2023 · 5 comments · Fixed by #7679
Closed

Formatter undocumented deviation: add comma after single argument definition #7323

JonathanPlasse opened this issue Sep 12, 2023 · 5 comments · Fixed by #7679
Assignees
Labels
documentation Improvements or additions to documentation formatter Related to the formatter

Comments

@JonathanPlasse
Copy link
Contributor

Black formatting

def main(
    pickle_path: Path = typer.Argument(
        "network_messages.pickle",
        help="The path of the pickle file that will contain the network messages",
    )
) -> None:
    start_async(launch_network_watcher, pickle_path)

Ruff formatting

def main(
    pickle_path: Path = typer.Argument(
        "network_messages.pickle",
        help="The path of the pickle file that will contain the network messages",
    ),
) -> None:
    start_async(launch_network_watcher, pickle_path)

Ruff 0.0.289 with line-length 100

@MichaReiser MichaReiser added formatter Related to the formatter needs-decision Awaiting a decision from a maintainer labels Sep 13, 2023
@MichaReiser MichaReiser added this to the Formatter: Beta milestone Sep 13, 2023
@MichaReiser
Copy link
Member

Interesting find. Black does add a trailing comma if the identifier doesn't fit but not when the type annotation or default value expands over multiple lines.

def main(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
) -> None:
    start_async(launch_network_watcher, pickle_path)


def main(
    pickle_path: Argument(
        "network_messages.pickle",
        help="The path of the pickle file that will contain the network messages",
    )
) -> None:
    start_async(launch_network_watcher, pickle_path)

This feels a bit inconsistent to me. We'll have to narrow down if this is intentional or not.

@charliermarsh
Copy link
Member

I ran into this at one point and I believe I came to the conclusion that it was unintentional and that the inconsistencies were hard to understand.

@charliermarsh
Copy link
Member

(I prefer the consistency of our formatting here, personally.)

@charliermarsh
Copy link
Member

charliermarsh commented Sep 13, 2023

I find the inconsistency here confusing:

def main(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
) -> None:
    start_async(launch_network_watcher, pickle_path)


def main(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=1,
) -> None:
    start_async(launch_network_watcher, pickle_path)


def main(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: Argument(
        "network_messages.pickle",
        help="The path of the pickle file that will contain the network messages",
    ) = 1
) -> None:
    start_async(launch_network_watcher, pickle_path)

I would vote to leave as-is.

@MichaReiser MichaReiser added wontfix This will not be worked on and removed needs-decision Awaiting a decision from a maintainer labels Sep 14, 2023
@charliermarsh
Copy link
Member

We're marking this as an intentional deviation. Can be closed once it's documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation formatter Related to the formatter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants