Skip to content

Commit 8ef21ee

Browse files
committed
Apply PEP 614
Check 'Named Expressions Need Not Be Parenthesized' Section
1 parent fccb4d6 commit 8ef21ee

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

Lib/test/test_decorators.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,12 @@ def unimp(func):
199199
code = compile(codestr, "test", "exec")
200200
self.assertRaises(exc, eval, code, context)
201201

202-
# TODO: RUSTPYTHON; := operator is invalid syntax
203-
# def test_expressions(self):
204-
# for expr in (
205-
# "(x,)", "(x, y)", "x := y", "(x := y)", "x @y", "(x @ y)", "x[0]",
206-
# "w[x].y.z", "w + x - (y + z)", "x(y)()(z)", "[w, x, y][z]", "x.y",
207-
# ):
208-
# compile(f"@{expr}\ndef f(): pass", "test", "exec")
202+
def test_expressions(self):
203+
for expr in (
204+
"(x,)", "(x, y)", "x := y", "(x := y)", "x @y", "(x @ y)", "x[0]",
205+
"w[x].y.z", "w + x - (y + z)", "x(y)()(z)", "[w, x, y][z]", "x.y",
206+
):
207+
compile(f"@{expr}\ndef f(): pass", "test", "exec")
209208

210209
def test_double(self):
211210
class C(object):

parser/src/python.lalrpop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ ClassDef: ast::Stmt = {
634634

635635
// Decorators:
636636
Decorator: ast::Expr = {
637-
<location:@L>"@" <p:Test> "\n" => {
637+
<location:@L>"@" <p:NamedExpressionTest> "\n" => {
638638
p
639639
},
640640
};

parser/src/python.rs

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)