Files
openide/python/testData/highlighting/illegalVariableAnnotationTarget.py
Mikhail Golubev b9d7fee816 PY-64304 EA-247016 Don't report illegal "await" expressions used as assignment targets during parsing
Instead, parse them as usual and later report in the dedicated AssignTargetAnnotator
and TypeAnnotationTargetAnnotator. This way, a PsiError element appearing in the PSI
tree of a type declaration statement doesn't cause PyAstTypeDeclarationStatement.getTarget
nullability contract violation.

GitOrigin-RevId: a3e90088cfac7938c398d4d293a72dbd127a2cd0
2024-04-24 09:03:53 +00:00

14 lines
885 B
Python

(x): int = 42
(((x))): float
x['foo']: str
f(42).attr: dict
<error descr="An illegal target for a variable annotation">2 ** 8</error>: int
<error descr="An illegal target for a variable annotation">f()</error>: bool
async def f():
<error descr="An illegal target for a variable annotation">await foo()</error>: int
<error descr="A variable annotation cannot be combined with tuple unpacking">x, y, z</error>: Tuple[int, ...]
(<error descr="A variable annotation cannot be combined with tuple unpacking">x, y, z</error>): Tuple[int, int, int]
<error descr="A variable annotation cannot be combined with tuple unpacking">[x, y, z]</error>: Tuple[Any, Any, Any]
<error descr="A variable annotation cannot be combined with tuple unpacking">x, *xs</error>: tuple = range(10)
<error descr="A variable annotation cannot be used in assignment with multiple targets">x:int = y = 42</error>