Repository navigation
Conversation
Override __copy__ and __deepcopy__ on BaseDataClass, basic-type metadata wrappers, and _EnumWrapper so copying a node detaches it from uncopied ancestors without walking up __rune_parent, while preserving parent links for descendants within the copied subtree. Add regression coverage for _clone_for_write, model_copy, copy/deepcopy, deep parent chains, and nested COW writes. Fixes finos#49 Signed-off-by: Walter Hawkins <wdhawkins46@gmail.com>
Extend BaseDataClass.resolve_references, _bind_property_to, _serialize_refs, _init_rune_parent, and resolve_ref_key to support multi-cardinality reference fields, while inferring allowed @ref tags from field validator metadata when _KEY_REF_CONSTRAINTS is absent. Update ComplexTypeMetaDataMixin.serialise, BasicTypeMetaDataMixin.serialise, and EnumWithMetaMixin.serialise to handle list, None, and reference values when serializers wrap list-typed or optional fields. Add regression coverage for list reference resolution, mixed inline and reference lists, assignment, dangling list references, and serialization roundtrips. Fixes finos#43 Signed-off-by: Walter Hawkins <wdhawkins46@gmail.com>
|
This PR has some substantial issues:
|
…tion, and detached subtree key registries Addresses review feedback on finos#54: 1. Introduce _ReferenceList to keep per-element reference bindings in sync across in-place mutations (__setitem__, reverse, pop, insert, del, extend, sort) and reconcile list references on resolve_references(), validation, and serialization. 2. Preserve existing resolved reference bindings across +=, list concatenation, plain-list copy-on-write assignments, and rune_cow / rune_unwrap list updates without emitting duplicate inline keys. 3. Validate all Reference items in sequence assignments atomically before mutating existing list items or reference bindings. 4. Rebuild RUNE_OBJ_MAPS key registries on detached deep and shallow subtree copies so Reference(key, parent=clone) and get_object_by_key() resolve against the copied subtree. Signed-off-by: Walter Hawkins <wdhawkins46@gmail.com>
|
Thanks for the thorough review @plamen-neykov. All four points are addressed in commit c69f193:
|
Summary
__rune_parenton copy while preserving in-subtree parent links (Fixes model_copy(deep=True) follows __rune_parent links, producing an attached copy instead of a detached subtree. #49):__copy__and__deepcopy__onBaseDataClass, basic-type metadata wrappers (BasicTypeMetaDataMixin/_DateTimeCopyMixin/NumberWithMeta), and_EnumWrappersomodel_copy(deep=True),_clone_for_write,copy.copy, andcopy.deepcopydetach the copied root from uncopied ancestors without traversing__rune_parentup the ancestor chain, while re-parenting cloned descendants inside the copied subtree.self.__dict__.get(name)inBaseDataClass.__setattr__somodel_copy(deep=True, update=...)does not raiseKeyErrorwhen copying__pydantic_private__.BaseDataClass.resolve_references,_bind_property_to,_serialize_refs,_init_rune_parent, andresolve_ref_keyto resolveUnresolvedReference/Referenceelements held inside sequence fields and serialize bound reference indices back as{@ref*: key}dicts.@ref*tags from field validator metadata when_KEY_REF_CONSTRAINTSis not explicitly defined on the model class.ComplexTypeMetaDataMixin.serialise,BasicTypeMetaDataMixin.serialise, andEnumWithMetaMixin.serialiseforNone,list, and reference values when serializers wrap list-cardinality or optional fields.Testing
test/test_rune_parent.py,test/test_keys_and_references.py, andtest/test_list_cardinality_with_meta.py.pytest --cov=rune.runtime(369 passed).