Skip to content

An ergonomic way to build Python Concrete Syntax Trees.

License

Notifications You must be signed in to change notification settings

argyle-engineering/fluentcst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fluentcst

An ergonomic interface for libCST:

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:

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.

About

An ergonomic way to build Python Concrete Syntax Trees.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages