[3.12] gh-108983: Add more PEP 526 tests to test_grammar (GH-108984) (#109000)

gh-108983: Add more PEP 526 tests to `test_grammar` (GH-108984)
(cherry picked from commit 1fb20d42c5)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2023-09-08 06:16:02 -07:00 committed by GitHub
parent b9dfe60e8d
commit 9441005bcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -350,6 +350,11 @@ def test_var_annot_syntax_errors(self):
check_syntax_error(self, "x: int: str")
check_syntax_error(self, "def f():\n"
" nonlocal x: int\n")
check_syntax_error(self, "def f():\n"
" global x: int\n")
check_syntax_error(self, "x: int = y = 1")
check_syntax_error(self, "z = w: int = 1")
check_syntax_error(self, "x: int = y: int = 1")
# AST pass
check_syntax_error(self, "[x, 0]: int\n")
check_syntax_error(self, "f(): int\n")
@ -363,6 +368,12 @@ def test_var_annot_syntax_errors(self):
check_syntax_error(self, "def f():\n"
" global x\n"
" x: int\n")
check_syntax_error(self, "def f():\n"
" x: int\n"
" nonlocal x\n")
check_syntax_error(self, "def f():\n"
" nonlocal x\n"
" x: int\n")
def test_var_annot_basic_semantics(self):
# execution order