mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-39702: Relax grammar restrictions on decorators (PEP 614) (GH-18570)
This commit is contained in:
parent
116fd4af73
commit
be501ca241
8 changed files with 534 additions and 537 deletions
|
@ -226,6 +226,27 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
|
|||
self.check_suite("@funcattrs()\n"
|
||||
"def f(): pass")
|
||||
|
||||
self.check_suite("@False or x\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@d := x\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@lambda f: x(f)\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@[..., x, ...][1]\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@x(x)(x)\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@(x, x)\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@...\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@None\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@w @(x @y) @(z)\n"
|
||||
"def f(): pass")
|
||||
self.check_suite("@w[x].y.z\n"
|
||||
"def f(): pass")
|
||||
|
||||
# keyword-only arguments
|
||||
self.check_suite("def f(*, a): pass")
|
||||
self.check_suite("def f(*, a = 5): pass")
|
||||
|
@ -270,6 +291,27 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
|
|||
"@decorator2\n"
|
||||
"class foo():pass")
|
||||
|
||||
self.check_suite("@False or x\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@d := x\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@lambda f: x(f)\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@[..., x, ...][1]\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@x(x)(x)\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@(x, x)\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@...\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@None\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@w @(x @y) @(z)\n"
|
||||
"class C: pass")
|
||||
self.check_suite("@w[x].y.z\n"
|
||||
"class C: pass")
|
||||
|
||||
def test_import_from_statement(self):
|
||||
self.check_suite("from sys.path import *")
|
||||
self.check_suite("from sys.path import dirname")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue