New submission from Lysandros Nikolaou <lisandros...@gmail.com>: Brandt found this out while testing his implementation of the `match` statement. When a list or tuple are followed by a colon without an annotation, the old parser used to say "invalid syntax", while the new parser considers this an annotation and outputs something along the lines of "only single target (not tuple) can be annotated". For example:
➜ cpython git:(master) ./python.exe Python 3.10.0a0 (heads/master:06a40d7359, Jun 26 2020, 01:33:34) [Clang 11.0.3 (clang-1103.0.32.62)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> (a, b): File "<stdin>", line 1 (a, b): ^ SyntaxError: only single target (not tuple) can be annotated >>> [a, b]: File "<stdin>", line 1 [a, b]: ^ SyntaxError: only single target (not list) can be annotated >>> a,: File "<stdin>", line 1 a,: ^ SyntaxError: only single target (not tuple) can be annotated The behavior of the old parser seems more logical. ---------- assignee: lys.nikolaou messages: 372390 nosy: brandtbucher, gvanrossum, lys.nikolaou, pablogsal priority: normal severity: normal status: open title: Wrong error message for list/tuple followed by a colon type: behavior versions: Python 3.10, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41119> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com