LibCST
LibCST copied to clipboard
[low-pri][doc] Add document to explain the design differences between libcst and ast
ast and libcst looks similar but different in many design details. To make it more clear and prevent confusion for users familiar with ast (I'm one of them), it worth documents the differences with some paragraphs.
| Item with Difference | LibCST | ast |
|---|---|---|
| string value (e.g. asname in Import/ImportFrom) | Name | str |
| Name | value |
id |
| FunctionDef | FunctionDef | FunctionDef and AsyncFunctionDef |
| decorators in ClassDef | decorators |
decorator_list |
| access statement inside for or while loop | For.body.body[0].body.value (For.body is an IndentBlock, For.body.body[0] is a SimpleStatementLine, For.body.body[0].body[0] is a Expr.) |
For.body[0].value (body[0] is an Expr) |
| Call.args | Sequence[Arg], Arg.value stores the value |
Sequence[value] |
| keyword arg in Call | Arg in Call.args with Arg.keyword is not None | keyword.arg with keyword in Call.keywords |
| ImportFrom.module | Name or Attribute | str or Attribute |