tree-sitter / tree-sitter-python

Python grammar for tree-sitter
MIT License
360 stars 132 forks source link

bug: Multi-line string literal comments parsed as expression_statement instead of comment #268

Closed obonyojimmy closed 3 months ago

obonyojimmy commented 3 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

Multi-line string literal comments parsed as expression_statement instead of comment

Steps To Reproduce/Bad Parse Tree

  1. Parse a python class definition like below:

    class Hello:
    """
    A test hello class
    """
    def __init__(self):
     pass
  2. The parsed Tree for Hello class body , child 0 which is expected to be a comment is parsed as an expression_statement

Expected Behavior/Parse Tree

Would have expected a 'comment' Node , getting expression_statement

Repro

# Example code that causes the issue
class Hello:
  """
  A test hello class
  """
  def __init__(self):
     pass
amaanq commented 3 months ago

Those are strings, not comments. This is expected.

obonyojimmy commented 3 months ago

Those are strings, not comments. This is expected.

Thanks for the clarification