From 136930fccb99320865622e12ffc21bdd45fd7501 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Fri, 3 Dec 2021 17:49:33 +0300 Subject: [PATCH] Make star-expression spacing consistent in match/case (#2667) --- 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 fc198a8..e5f4a1f 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 437051d..8bf1934 100644 --- a/src/black/nodes.py +++ b/src/black/nodes.py @@ -97,6 +97,8 @@ UNPACKING_PARENTS: Final = { 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 095c1a2..60ad8a3 100644 --- a/tests/data/pattern_matching_extras.py +++ b/tests/data/pattern_matching_extras.py @@ -77,3 +77,8 @@ match match( match match: case case: pass + + +match a, *b(), c: + case d, *f, g: + pass -- 2.39.5