From 147d075a4c702ffd6822100dc1f7a6384e52fa57 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Sun, 14 Nov 2021 17:04:31 +0300 Subject: [PATCH] black/parser: support as-exprs within call args (#2608) --- src/blib2to3/Grammar.txt | 1 + tests/data/pattern_matching_extras.py | 9 +++++++++ tests/test_format.py | 1 + 3 files changed, 11 insertions(+) create mode 100644 tests/data/pattern_matching_extras.py diff --git a/src/blib2to3/Grammar.txt b/src/blib2to3/Grammar.txt index 49680323d8b..c2a62543abb 100644 --- a/src/blib2to3/Grammar.txt +++ b/src/blib2to3/Grammar.txt @@ -186,6 +186,7 @@ arglist: argument (',' argument)* [','] # that precede iterable unpackings are blocked; etc. argument: ( test [comp_for] | test ':=' test | + test 'as' test | test '=' test | '**' test | '*' test ) diff --git a/tests/data/pattern_matching_extras.py b/tests/data/pattern_matching_extras.py new file mode 100644 index 00000000000..b17922d608b --- /dev/null +++ b/tests/data/pattern_matching_extras.py @@ -0,0 +1,9 @@ +match something: + case [a as b]: + print(b) + case [a as b, c, d, e as f]: + print(f) + case Point(a as b): + print(b) + case Point(int() as x, int() as y): + print(x, y) diff --git a/tests/test_format.py b/tests/test_format.py index 4359deea92b..8f8ffb3610e 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -73,6 +73,7 @@ PY310_CASES = [ "pattern_matching_simple", "pattern_matching_complex", + "pattern_matching_extras", "parenthesized_context_managers", ]