LibCST icon indicating copy to clipboard operation
LibCST copied to clipboard

Add data to nodes

Open nschloe opened this issue 3 years ago • 1 comments

I would like to add some data around cst objects, e.g., for function calls where the function was defined. To this end, I need to add attributes to cst objects, see this discussion. Unfortunately, this is not possible right now since all objects are protected from adding attributes via __slotted__ (or @add_slots).

Is there another way for adding data to nodes?

nschloe avatar Jan 05 '23 17:01 nschloe

Normally I'd recommend metadata providers for this; while they're a bit cumbersome, they essentially let you store arbitrary data keyed by the identity of a CSTNode.

zsol avatar May 25 '23 18:05 zsol