Instagram / LibCST

A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
https://libcst.readthedocs.io/
Other
1.57k stars 192 forks source link

ParserSyntaxError for "unmatched ']'" faults wrong location #1112

Open thatch opened 9 months ago

thatch commented 9 months ago

I suspect this is an upstream issue, but documenting the repro so we can know if it gets fixed:

"""docstring"""
import a
import b
def foo(data: str) -> tuple[str, ...], frozenset[str]]:
  pass

(note too many close brackets at the end of the def line)

libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
tokenizer error: unmatched ']'

"""docstring"""
^

faults the first line of the file, when there is clearly one specific byte that can be faulted -- the extra close bracket.

thatch commented 3 weeks ago

Hit this again today via ufmt, forgot I filed this one before :)