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: Add parentheses around too long strings #6059

Closed
Tracked by #6069
konstin opened this issue Jul 25, 2023 · 1 comment
Closed
Tracked by #6069

Formatter: Add parentheses around too long strings #6059

konstin opened this issue Jul 25, 2023 · 1 comment
Labels
formatter Related to the formatter

Comments

@konstin
Copy link
Member

konstin commented Jul 25, 2023

The formatter currently never adds parentheses around strings in the right hand side of an assignment. Black does add them if they help to match the line limit, otherwise it doesn't.

Input and identical ruff formatted output:

DEFAULT_FILE_STORAGE_DEPRECATED_MSG = "The DEFAULT_FILE_STORAGE setting is deprecated. Use STORAGES instead."
DEFAULT_FILE_STORAGE_DEPRECATED_MSG = "The DEFAULT_FILE_STORAGE setting is deprecated. Use STORAGES instead. This makes it so long that parentheses don't help"

Black formatted output:

DEFAULT_FILE_STORAGE_DEPRECATED_MSG = (
    "The DEFAULT_FILE_STORAGE setting is deprecated. Use STORAGES instead."
)
DEFAULT_FILE_STORAGE_DEPRECATED_MSG = "The DEFAULT_FILE_STORAGE setting is deprecated. Use STORAGES instead. This makes it so long that parentheses don't help"
@MichaReiser
Copy link
Member

Closing because it is a sub problem of #6271

@MichaReiser MichaReiser added this to the Formatter: Alpha milestone Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

No branches or pull requests

2 participants