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

Can not format method code when method str parameter length default value too long #4150

Closed
pengdada00100 opened this issue Jan 12, 2024 · 5 comments
Labels
T: bug Something isn't working

Comments

@pengdada00100
Copy link

pengdada00100 commented Jan 12, 2024

Describe the bug

Can not format method code when method str parameter length default value too long

To Reproduce
env: python 3.8.10
black: 23.12.1

def demo_method(
    param1="this is a long long long long long long long long long long long long long long long long long long long long string",
):
    a = (
        "this is a long long long long long long long long long long long long long long long long"
        " long long long long string"
    )
    pass


if __name__ == "__main__":
    pass

And run it with these arguments:

python -m black .

The resulting is:

cannot format file.py without error, But the 'param1="this is a long long long long long long long long long long long long long long long long long long long long string"' can not format

Expected behavior

The default param should be format

Environment

  • Black's version: 23.12.1
  • OS and Python version:

Additional context
Also I can define a string constant out of this method and pass the constant to the method.
But I think black should format this scene

@pengdada00100 pengdada00100 added the T: bug Something isn't working label Jan 12, 2024
@hauntsaninja
Copy link
Collaborator

Hm, I can't reproduce the crash with Black 23.12.1 on that file with either preview or regular style.

Maybe try making a repro over at https://black.vercel.app/? (although note that uses v24.a1)

@JelleZijlstra
Copy link
Collaborator

Are you saying that Black is crashing, or just that in Black's output the line is still too long?

@pengdada00100
Copy link
Author

output the line is still too long

@hauntsaninja
Copy link
Collaborator

In that case, I think this is basically a duplicate of #3497

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants