Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mayalenE opened this issue Oct 24, 2022 · 0 comments
Open

Comments

@mayalenE
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant