lark-parser / lark

Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
MIT License
4.64k stars 397 forks source link

Type of `tree.data` is wrong. #1374

Closed naddeoa closed 7 months ago

naddeoa commented 7 months ago

https://github.com/lark-parser/lark/blob/942366b49247e996e387cb901ed96c7d861382a0/lark/tree.py#L58

The type claims that Tree.data is a str but in practice, when you print(type(tree.data)) it's a actually of type lark.lexer.Token.

ast = lark.parse(example)
print(type(ast.data))
naddeoa commented 7 months ago

Just noticed it's a subclass of str, wasn't expecting that.