https://github.com/argyle-engineering/fluentcst
An ergonomic way to build Python Concrete Syntax Trees.
https://github.com/argyle-engineering/fluentcst
ast codegen libcst python
Last synced: 4 months ago
JSON representation
An ergonomic way to build Python Concrete Syntax Trees.
- Host: GitHub
- URL: https://github.com/argyle-engineering/fluentcst
- Owner: argyle-engineering
- License: mit
- Created: 2023-02-28T15:21:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-03T19:11:15.000Z (11 months ago)
- Last Synced: 2025-04-19T10:58:24.914Z (9 months ago)
- Topics: ast, codegen, libcst, python
- Language: Python
- Homepage:
- Size: 239 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# fluentcst
An ergonomic interface for [libCST](https://github.com/Instagram/LibCST):
```py
import fluentcst as fcst
module = fcst.Module()
module.require_import("BaseModel", from_="pydantic")
module.add(
fcst.ClassDef("MyModel")
.base("BaseModel")
.field(version="1.2.3")
.field(status={"code": "200", "message": "OK"})
.field(items=[fcst.Call("Item", name="i1", value="v1")])
)
print(module.to_code())
```
that builds valid Python code:
```py
from pydantic import BaseModel
class MyModel(BaseModel):
version = "1.2.3"
status = {"code": "200", "message": "OK"}
items = [Item(name = "i1", value = "v1")]
```
Highly Work in Progress. Expect interface to break, a lot.