From 2fb7724062193912d1a4c5c69dee2819327da4db Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Fri, 3 Dec 2021 17:24:13 +0300 Subject: [PATCH] Make star-expression spacing consistent in match/case --- CHANGES.md | 1 + src/black/nodes.py | 2 ++ tests/data/pattern_matching_extras.py | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index fc198a8f8c0..e5f4a1fdf82 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - Fix `match`/`case` statements that contain `match`/`case` soft keywords multiple times, like `match re.match()` (#2661) - Fix `case` statements with an inline body (#2665) +- Fix styling of starred expressions inside `match` subject (#2667) - Fix assignment to environment variables in Jupyter Notebooks (#2642) - Add `flake8-simplify` and `flake8-comprehensions` plugins (#2653) - Fix determination of f-string expression spans (#2654) diff --git a/src/black/nodes.py b/src/black/nodes.py index 437051d3f6d..8bf1934bc2a 100644 --- a/src/black/nodes.py +++ b/src/black/nodes.py @@ -97,6 +97,8 @@ syms.listmaker, syms.testlist_gexp, syms.testlist_star_expr, + syms.subject_expr, + syms.pattern, } TEST_DESCENDANTS: Final = { syms.test, diff --git a/tests/data/pattern_matching_extras.py b/tests/data/pattern_matching_extras.py index 095c1a2b3bb..60ad8a3d81b 100644 --- a/tests/data/pattern_matching_extras.py +++ b/tests/data/pattern_matching_extras.py @@ -77,3 +77,8 @@ def func(match: case, case: match) -> case: match match: case case: pass + + +match a, *b(), c: + case d, *f, g: + pass