From 3bc182b0946e10c39eb6133b4ceb08107c35c9eb Mon Sep 17 00:00:00 2001 From: Chris Pryer Date: Mon, 17 Jul 2023 11:36:20 -0400 Subject: [PATCH] Add tuple target fixture to `DictComp` fixture --- .../fixtures/ruff/expression/dict_comp.py | 32 +++++ .../format@expression__dict_comp.py.snap | 115 +++++++++++++++++- 2 files changed, 146 insertions(+), 1 deletion(-) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py index d4c68f01a5f75..87b0c035a7448 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py @@ -43,3 +43,35 @@ if gggggggggggggggggggggggggggggggggggggggggggg } + +# Useful for tuple target (see https://github.com/astral-sh/ruff/issues/5779#issuecomment-1637614763) +{k: v for a, a, a, a, a, a, a, a, a, a, [a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a] in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension} +{k: v for a, a, a, a, a, a, a, a, a, a, (a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension} + +# Leading +{ # Leading + k: v # Trailing + for a, a, a, a, a, a, a, a, a, a, ( # Trailing + a, + a, + a, + a, + a, + a, + a, + a, + a, # Trailing + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, # Trailing + ) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension # Trailing +} # Trailing +# Trailing \ No newline at end of file diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap index 49582d167eae7..1887490574c34 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__dict_comp.py.snap @@ -49,7 +49,38 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression if gggggggggggggggggggggggggggggggggggggggggggg } -``` + +# Useful for tuple target (see https://github.com/astral-sh/ruff/issues/5779#issuecomment-1637614763) +{k: v for a, a, a, a, a, a, a, a, a, a, [a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a] in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension} +{k: v for a, a, a, a, a, a, a, a, a, a, (a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension} + +# Leading +{ # Leading + k: v # Trailing + for a, a, a, a, a, a, a, a, a, a, ( # Trailing + a, + a, + a, + a, + a, + a, + a, + a, + a, # Trailing + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, # Trailing + ) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension # Trailing +} # Trailing +# Trailing``` ## Output ```py @@ -104,6 +135,88 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression < hhhhhhhhhhhhhhhhhhhhhhhhhh if gggggggggggggggggggggggggggggggggggggggggggg } + +# Useful for tuple target (see https://github.com/astral-sh/ruff/issues/5779#issuecomment-1637614763) +{ + k: v + for a, a, a, a, a, a, a, a, a, a, [ + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + ] in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension +} +{ + k: v + for a, a, a, a, a, a, a, a, a, a, ( + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + ) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension +} + +# Leading +{ + # Leading + k: v # Trailing + for a, a, a, a, a, a, a, a, a, a, ( + # Trailing + a, + a, + a, + a, + a, + a, + a, + a, + a, # Trailing + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, + a, # Trailing + ) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension # Trailing +} # Trailing +# Trailing ```