-
Notifications
You must be signed in to change notification settings - Fork 54
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
Support for attrs dataclasses #261
Comments
Hello there @bilelomrani1, thanks for posting! Hmm that's interesting. Does For
If there's a way of get this information from the |
Hey @bilelomrani1, do you know if |
Hi @lebrice I'm sorry for the long delay. I no longer need this feature as I found an existing alternative for my use case. But I can still provide some answers if you are still interested in this feature, I once wrote a dataclasses/attrs parser some time ago, the code is available here.
|
Hi @lebrice, I'm interested in this integration too! For your questions:
Yes, absolutely!
attrs.fields(cls) -> tuple[attrs.Attribute, ...]
attrs.has(cls) -> bool
https://www.attrs.org/en/stable/api.html#attrs.Attribute For the record, the dataclass module is heavily inspired by the I'd be happy to help explore this further! What are your thoughts? |
Sure, we can add support for attrs dataclasses. A first step could probably be to replace all the uses of the functions from dataclasses with generic functions with the same name, that dispatch either to the attrs function or dataclasses function depending on the class /field type. If you're willing to help with that, I'd be happy to give some pointers or feedback! |
attrs is a popular third-party package for defining dataclasses with additional convenient features (converters, more fine-grained initialization, etc.). Currently
simple-parsing
only supports native dataclasses, is there any interest to support attrs dataclasses as well?The text was updated successfully, but these errors were encountered: