Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Lib/test/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,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")
Expand All @@ -368,6 +373,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
Expand Down