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

lazy_instance and dataclasses ? #642

Open
cgebbe opened this issue Dec 8, 2024 · 1 comment
Open

lazy_instance and dataclasses ? #642

cgebbe opened this issue Dec 8, 2024 · 1 comment
Labels

Comments

@cgebbe
Copy link

cgebbe commented Dec 8, 2024

🚀 Feature request

Thanks for this awesome library! I would like the following simple example to work:

import jsonargparse
from dataclasses import dataclass

@dataclass
class Bar:
    x: int

bar=jsonargparse.lazy_instance(Bar, x=3)
bar.x

Motivation

I really like lazy_instance: Its much nicer than writing long, nested YAML files, but still translates into a nice config Namespace which can be easily reused. However, currently, dataclasses don't seem to be really supported

@cgebbe cgebbe added the enhancement New feature or request label Dec 8, 2024
@mauvilsa
Copy link
Member

Thank you for proposing improvements!

Could you please clarify a bit? lazy_instance is not intended to be used alone (like above), but only to avoid actual instance defaults in signatures. Also, lazy_instance doesn't return a Namespace, so I am a bit confused by the motivation or how that relates to YAML files.

I do see that lazy_instance is not working for dataclasses, but I am not sure there is a need for it.

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

No branches or pull requests

2 participants