Esempio n. 1
0
 def parse_comments(self) -> None:
     """Parse the code and pick up comments."""
     tree = parse(self.code)
     picker = VariableCommentPicker(self.code.splitlines(True), self.encoding)
     picker.visit(tree)
     self.annotations = picker.annotations
     self.comments = picker.comments
     self.deforders = picker.deforders
Esempio n. 2
0
def test_unparse_py38(source, expected):
    module = ast.parse(source)
    assert ast.unparse(module.body[0].value, source) == expected
Esempio n. 3
0
def test_unparse_py38():
    source = "lambda x=0, /, y=1, *args, z, **kwargs: x + y + z"
    expected = "lambda x=0, /, y=1, *args, z, **kwargs: ..."
    module = ast.parse(source)
    assert ast.unparse(module.body[0].value) == expected