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

Improved string processing POC #7237

Closed
MichaReiser opened this issue Sep 8, 2023 · 1 comment
Closed

Improved string processing POC #7237

MichaReiser opened this issue Sep 8, 2023 · 1 comment
Assignees
Labels
formatter Related to the formatter

Comments

@MichaReiser
Copy link
Member

Create a POC for #6936 to explore possible implementations and the performance implications.

@MichaReiser MichaReiser self-assigned this Sep 8, 2023
@MichaReiser MichaReiser added this to the Formatter: Beta milestone Sep 8, 2023
@MichaReiser MichaReiser added the formatter Related to the formatter label Sep 8, 2023
@MichaReiser
Copy link
Member Author

Learnings so far

  • Black picks the preferred quote depending on the string parts that it merges. Meaning, the implicit string concatenation may have some parts that use single and other parts that use double quotes, depending on what requires the fewest escape for that specific line. Implementing this in Ruff is probably very hard, if not impossible. Ruff normalizes the entire string and picks a single quote for all parts
  • I need to investigate if black applies the same formatting for triple quoted strings, and if it does, where ruff breaks these strings correctly. It could be a problem that the separator in 'flat' mode requires less space than the separator in expanded mode (one space vs triple quotes).

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

1 participant