horast icon indicating copy to clipboard operation
horast copied to clipboard

docstring not parsed correctly

Open ZdenekM opened this issue 4 years ago • 2 comments

Following simple test fails:

import horast
import inspect

class Test:
    """
    multiline
    docstring
    """

original_code = inspect.getsource(Test)
tree = horast.parse(original_code)
unparsed_code = horast.unparse(tree)
assert original_code == unparsed_code

because tree looks like this:

Module(
  body=[ClassDef(
    name='Test',
    bases=[],
    keywords=[],
    body=[Expr(value=Str(
      s='\n    multiline\n    docstring\n    ',
      kind=''))],
    decorator_list=[])],
  type_ignores=[])

Would it be possible to fix this somehow? I can probably use some temporary workaround, but it would be really nice to have this working out of the box. I'm going to generate classes/methods with docstrings.

ZdenekM avatar Apr 09 '20 05:04 ZdenekM