From 9728b8e9b8720b5e401249c077e32de46a479161 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 1 Feb 2024 21:58:51 -0800 Subject: [PATCH] Move hug_parens_with_braces_and_square_brackets into the unstable style (#4198) Primarily because of #4036 (a crash) but also because of the feedback in #4098 and #4099. --- CHANGES.md | 3 +++ docs/the_black_code_style/future_style.md | 4 ++-- src/black/mode.py | 2 ++ .../preview_hug_parens_with_braces_and_square_brackets.py | 2 +- ...eview_hug_parens_with_braces_and_square_brackets_no_ll1.py | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a3ffba610d9..4d646a2779e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,9 @@ +- Move the `hug_parens_with_braces_and_square_brackets` feature to the unstable style + due to an outstanding crash and proposed formatting tweaks (#4198) + ### Configuration - _Black_ now ignores `pyproject.toml` that is missing a `tool.black` section when diff --git a/docs/the_black_code_style/future_style.md b/docs/the_black_code_style/future_style.md index 1c11186f811..86e5aa806b2 100644 --- a/docs/the_black_code_style/future_style.md +++ b/docs/the_black_code_style/future_style.md @@ -24,8 +24,6 @@ Currently, the following features are included in the preview style: strings - `unify_docstring_detection`: fix inconsistencies in whether certain strings are detected as docstrings -- `hug_parens_with_braces_and_square_brackets`: more compact formatting of nested - brackets ([see below](labels/hug-parens)) - `no_normalize_fmt_skip_whitespace`: whitespace before `# fmt: skip` comments is no longer normalized - `typed_params_trailing_comma`: consistently add trailing commas to typed function @@ -41,6 +39,8 @@ The unstable style additionally includes the following features: ([see below](labels/wrap-long-dict-values)) - `multiline_string_handling`: more compact formatting of expressions involving multiline strings ([see below](labels/multiline-string-handling)) +- `hug_parens_with_braces_and_square_brackets`: more compact formatting of nested + brackets ([see below](labels/hug-parens)) (labels/hug-parens)= diff --git a/src/black/mode.py b/src/black/mode.py index 22352e7c6a8..5738bd6b793 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -186,6 +186,8 @@ class Preview(Enum): Preview.wrap_long_dict_values_in_parens, # See issue #4159 Preview.multiline_string_handling, + # See issue #4036 (crash), #4098, #4099 (proposed tweaks) + Preview.hug_parens_with_braces_and_square_brackets, } diff --git a/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets.py b/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets.py index 47a6a0bcae6..cbbcf16d3bd 100644 --- a/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets.py +++ b/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets.py @@ -1,4 +1,4 @@ -# flags: --preview +# flags: --unstable def foo_brackets(request): return JsonResponse( { diff --git a/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets_no_ll1.py b/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets_no_ll1.py index fdebdf69c20..16ebea379bc 100644 --- a/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets_no_ll1.py +++ b/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets_no_ll1.py @@ -1,4 +1,4 @@ -# flags: --preview --no-preview-line-length-1 +# flags: --unstable --no-preview-line-length-1 # split out from preview_hug_parens_with_brackes_and_square_brackets, as it produces # different code on the second pass with line-length 1 in many cases. # Seems to be about whether the last string in a sequence gets wrapped in parens or not.