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
/Users/bgraham/projects/240103_named_tuple/asdf/asdf/treeutil.py:360: AsdfWarning: Failed to serialize instance of <class '__main__.NT'>, converting to list instead
warnings.warn(f"Failed to serialize instance of {type(node)}, converting to list instead", AsdfWarning)
<class 'list'>
The warning can be silenced by passing ignore_implicit_conversion=True when creating the AsdfFile instance.
The conversion to a list loses the by-name item access possible with namedtuple.
This prevents creation of any Converter to support a specific namedtuple.
If the following line is changed to use type(node) == tuple:
In summary, the current way that namedtuple is supported seems incomplete and hinders customization by users.
I propose that we deprecate ignore_implicit_conversion drop our current "support" for namedtuple and allow users to implement Converter instances for any namedtuples they would like to serialize/deserialize.
The text was updated successfully, but these errors were encountered:
Attempts to store a
namedtuple
instance in the tree result in behavior that doesn't match with other custom objects.produces
The warning can be silenced by passing
ignore_implicit_conversion=True
when creating theAsdfFile
instance.The conversion to a list loses the by-name item access possible with
namedtuple
.This prevents creation of any
Converter
to support a specificnamedtuple
.If the following line is changed to use
type(node) == tuple
:asdf/asdf/treeutil.py
Line 368 in 334f6c3
it becomes possible to put
namedtuple
instances in the tree and to implementConverter
instances for specificnamedtuple
classes. See the following:In summary, the current way that
namedtuple
is supported seems incomplete and hinders customization by users.I propose that we deprecate
ignore_implicit_conversion
drop our current "support" fornamedtuple
and allow users to implementConverter
instances for anynamedtuples
they would like to serialize/deserialize.The text was updated successfully, but these errors were encountered: