Skip to content

Creating a Dict from instances of classes that inherit from NamedTuple #150

@mayalenE

Description

@mayalenE

Hello,

I'm trying to use Dict with MaskedNode objects used in the optax library which are class that are empty and inherit from NamedTuple: https://github.com/deepmind/optax/blob/master/optax/_src/wrappers.py

It is possible to create dict with those objects but the Dict construction is failing, here is a minimal example:

from addict import Dict
from typing import NamedTuple

class MyNamedTuple(NamedTuple):
    """
    """

mn_dict = dict(mn=MyNamedTuple())
print(mn_dict)
mn_Dict = Dict(mn=MyNamedTuple()) 

Would it be possible to include this case and match dict constructor?
Thank you very much,

Mayalen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions