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

Consider preferring preferred quote style if both styles require backslashes #8264

Closed
charliermarsh opened this issue Oct 26, 2023 · 2 comments
Labels
formatter Related to the formatter style How should formatted code look

Comments

@charliermarsh
Copy link
Member

Given:

"json enter input={'a': 2} kwargs={\"strict\": None, \"context\": {\"c\": 2}}"

Black will reformat as:

'json enter input={\'a\': 2} kwargs={"strict": None, "context": {"c": 2}}'

Ruff does the same thing, so it's not a compatibility issue. But I'm wondering if it makes more sense to bias towards the preferred quote style if you need backslashes regardless (even if the non-preferred style results in fewer backslashes).

This came up in the Pydantic migration: https://github.com/pydantic/pydantic/pull/7930/files#r1373829517

@charliermarsh charliermarsh added the formatter Related to the formatter label Oct 26, 2023
@MichaReiser MichaReiser added the needs-decision Awaiting a decision from a maintainer label Oct 26, 2023
@MichaReiser
Copy link
Member

MichaReiser commented Oct 26, 2023

I'm leaning toward Black compatibility. It doesn't seem we have strong reasoning to diverge. E.g. for the above example, I find Black's formatting easier to read and it results in a shorter string overall.

"json enter input={'a': 2} kwargs={\"strict\": None, \"context\": {\"c\": 2}}"

@MichaReiser MichaReiser added needs-decision Awaiting a decision from a maintainer style How should formatted code look and removed needs-decision Awaiting a decision from a maintainer labels Oct 26, 2023
@MichaReiser
Copy link
Member

It doesn't seem to have come up again. We can improve our documentation if this comes up more often. @charliermarsh feel free to re-open if you disagree with my decision.

@MichaReiser MichaReiser closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 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 style How should formatted code look
Projects
None yet
Development

No branches or pull requests

2 participants