Skip to content

wrap_long_dict_values_in_parens: Respect user choice if no delimiters - #5627

Open
cobaltt7 wants to merge 8 commits into
psf:mainfrom
cobaltt7:gh-4882
Open

cobaltt7 wants to merge 8 commits into
psf:mainfrom
cobaltt7:gh-4882

Conversation

@cobaltt7

Copy link
Copy Markdown
Collaborator

Description

Closes #4882
Instead of requiring no parens when there's no delimiters (as discussed on the issue), I choice to respect users' choice. While this adds a dependency on previous formatting, many of the examples in the test case were formatted worse without the parens.

Checklist - did you ...

  • [y] Implement any code style changes under the --preview style, following the stability policy?
  • [y] Add an entry in CHANGES.md if necessary?
  • [y] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?

Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

diff-shades results comparing this PR (b7c13cc) to main (9a1f64e):

--preview style (View full diff):
╭───────────────────────── Summary ──────────────────────────╮
│ 11 projects & 84 files changed / 2006 changes [+584/-1422] │
│                                                            │
│ ... out of 3 146 638 lines, 14 240 files & 22 projects     │
╰────────────────────────────────────────────────────────────╯

Differences found.

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
Signed-off-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
@cobaltt7

cobaltt7 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Note: it was mentioned on the issue how triple-quoted strings were always wrapped in parens too. I changed that to only wrap concatenated strings in parens (as with single-quoted strings), but kept those dicts containing single triple quoted strings broken.

# Stable
{"a": """
"""}

# Preview (main)
{
     "a": (
        """
"""
    )
}

# Preview (this PR)
{
     "a": """
"""
}

@cobaltt7
cobaltt7 requested a review from hauntsaninja October 28, 2026 16:36
@cobaltt7 cobaltt7 added the S: needs discussion Needs further hashing out before ready for implementation (on desirability, feasibility, etc.) label Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S: needs discussion Needs further hashing out before ready for implementation (on desirability, feasibility, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thinking about wrap_long_dict_values_in_parens

1 participant