You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This being a consciously minimal (read: heinous) hack job at the moment, little of a decorated class' metadata survives the transformation. Tab complete doesn't work, nothing useful shown on hover, etc.
(Note I am talking about Python class metadata, not attrs field metadata.)
We want all the original metadata, modified with some new attributes: name, parent, etc.
I think we don't need to wrap/replace the class init method as is done now. Better to build on attrs as much as possible*. @xattree can wrap @attrs.define(), use field_transformer to add the new fields, and use a post-init hook to create the datatree? With that (plus maybe functools.wrap?) I think attrs will do the rest, and metadata will work.
*To guarantee metadata, attrs rewrites the classes by hand, compiles them, and registers them globally. Trickery best left to experts.
The text was updated successfully, but these errors were encountered:
For some reason the new fields aren't showing up in hover, tab complete, etc. Only the old fields. I figured field_transformer would make this work. Maybe the mypy plugin hack is necessary too? But the VSCode python extensions runs on pyright which should be covered by dataclass_transform?
This being a consciously minimal (read: heinous) hack job at the moment, little of a decorated class' metadata survives the transformation. Tab complete doesn't work, nothing useful shown on hover, etc.
(Note I am talking about Python class metadata, not
attrs
field metadata.)We want all the original metadata, modified with some new attributes:
name
,parent
, etc.I think we don't need to wrap/replace the class init method as is done now. Better to build on
attrs
as much as possible*.@xattree
can wrap@attrs.define()
, usefield_transformer
to add the new fields, and use a post-init hook to create the datatree? With that (plus maybefunctools.wrap
?) I thinkattrs
will do the rest, and metadata will work.*To guarantee metadata,
attrs
rewrites the classes by hand, compiles them, and registers them globally. Trickery best left to experts.The text was updated successfully, but these errors were encountered: