Closed
Description
While reading https://peps.python.org/pep-0526/#where-annotations-aren-t-allowed I've noticed that not all corner-cases are covered:
cpython/Lib/test/test_grammar.py
Lines 347 to 365 in 6f8411c
For example, explicit PEP's example:
def f():
global x: int # SyntaxError
def g():
x: int # Also a SyntaxError
global x
Two problems:
global x: int
is not tested, onlynonlocal x: int
isx: int; nonlocal x
is not tested
There's also an interesting corner-case from the rejected ideas:
x: int = y = 1
z = w: int = 1
Since, we have this test check_syntax_error(self, "def f: int")
, I assume that we also test rejected ideas here. So, let's add this one as well.
I propose adding these three cases.