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

Format one-tuples and one-subscripts as multi-line if already multi-line #4038

Closed
wants to merge 5 commits into from

Conversation

bluetech
Copy link
Contributor

@bluetech bluetech commented Nov 9, 2023

This implement the proposal in #3918.

I wasn't sure if this needs to go as a preview option; it shouldn't affect already formatted code (so adheres to the Stability Policy), but it does change how unformatted input is formatted.

Split to multiple commits to make reviewing a bit easier. Can be squashed to a single commit. The actual meaningful change is the last commit.

I've used opening.lineno != closing.lineno as an easy way to detect "multiline". I think it's correct and simple but maybe it's not appropriate.

Tested on some of our projects and it has the intended effect. For skip-magic-trailing-comma = true configurations it should have no effect at all.

No logical changes (the `token.RPAR` is the only remaining option in
CLOSING_BRACKETS)
Make the `closing.opening_bracket is None` handling the same as in RSQB;
though I don't think this happen in practice IIUC.
Since 72e7a2e is no longer true (and it
wasn't true before either)
Copy link

diff-shades results comparing this PR (0a79e73) to main (58f31a7). The full diff is available in the logs under the "Generate HTML diff report" step.

╭─────────────────────── Summary ────────────────────────╮
│ 2 projects & 4 files changed / 18 changes [+13/-5]     │
│                                                        │
│ ... out of 2 514 425 lines, 11 770 files & 23 projects │
╰────────────────────────────────────────────────────────╯

Differences found.

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

@bluetech
Copy link
Contributor Author

I started looking into the SQLAlchemy diff-shades stability failure. I minimized it to the following failure:

Mode(target_versions={<TargetVersion.PY38: 8>}, line_length=79, string_normalization=True, is_pyi=False, is_ipynb=False, skip_source_first_line=False, magic_trailing_comma=True, experimental_string_processing=False, python_cell_magics=set(), preview=True)
--- source
+++ first pass
@@ -1,8 +1,6 @@
 if True:
     if True:
         if ooooooooooooooooooooooooo and oooooooooooooooooo[ooo].oooooooo == (
             0,
         ):
-            Baz(
-                ""
-            )
+            Baz("")
--- first pass
+++ second pass
@@ -1,6 +1,6 @@
 if True:
     if True:
-        if ooooooooooooooooooooooooo and oooooooooooooooooo[ooo].oooooooo == (
-            0,
-        ):
+        if ooooooooooooooooooooooooo and oooooooooooooooooo[
+            ooo
+        ].oooooooo == (0,):
             Baz("")

However when I try to understand what happens in the second pass by running black on the output of the first pass, I get no changes. So I'm a bit stumped; maybe I misunderstood how it works and the second pass is not just running black again on the output of the first pass? I'll try figure it out, in the meantime I'll mark the PR as draft.

@bluetech bluetech marked this pull request as draft November 11, 2023 19:12
@bluetech
Copy link
Contributor Author

Will close this for now, might try again in the future.

@bluetech bluetech closed this Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant