-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feedback Requested #3
Comments
Hey! I really like the library - it's really elegant and it works! I've been using it extensively in a package (not-yet publicly available). I'll open a separate issue about the fixed Attrs version (need to support a newer version) |
First reasonable library I came across on this 'modern' language. Thanks for doing this. Documentation is a bit lacking and an example with JSON would be nice |
Looks like a great library, but, I've hit unserializable decimals and enums. |
Thanks @ambivalentno! Just as an FYI, you can use Enums as ChildFields. But making it an explicit might be helpful. Nothing with decimals explicitly or implicitly. So great to have them added. There are a couple of tests with enums: Specifically: |
Also, have you thought about serialization/deserialization speed comparison with existing libraries? |
Merged the PR. Thanks again. Will update the version shortly. Which respect to speed comparisons? Do you mean with using ujson instead or json for converting to JSON or comparing related to something like cattrs or schematics? I'm interested, but not exactly a top priority since I mostly use this library for configuration files and other non-performance critical features. But moar speed is always great. |
Do you mean with using ujson instead or json for converting to JSON or comparing related to something like cattrs or schematics? |
Hello! I'm playing with related and it looks really nice! Could you help with this case:
At the end, I want to have a list with two different classes:
is it possible? |
Hard to tell from an artificial example your exact goals, but both of these examples work. I prefer the 2nd example but it doesn't meet your specific requirement of 2 different child class types. It also uses two special flags in the YAML serializer function. Example 1
Example 2
Hope that helps! |
Thanks for your answer, Ian! I want different classes because I want to validate that:
The first example validates it as I want, but unfortunately, I cannot tell how many entries will be in the conf map. It's a config file and there can be several entries, some with type=a and others with type=b
So, I want to make sure, that run-prog-* actions will always have "command" field |
@olfway since this is so specialized you might want to create your own field type with it's own converter that invokes to_model passing in a class based on a child dictionary value. It's not super hard to do once you understand the pattern. Here is the "field type" to copy: Line 141 in 781a33c
Here is the converter to copy: related/src/related/converters.py Line 80 in 781a33c
I provided the links to the Mapping Field, but since order probably is important, you might want to consider switching to the Sequence Field as your starting point. |
Thanks, I'll try it |
I like this library a lot, but I can't get past a problem I'm having with SeqeunceFields. I have an Authorization object:
But whenever I try to pass a dict with a lift of Capability objects into the load function it gives me an error.
This gives me: I've tried converting passing in What am I doing wrong? Edit: I figured it out, I was importing the Authorization class wrong. |
A lot about this library is really appealing, thank you. I've tried it out by starting a DYN implementation with it. Some of the questions I had while doing it:
EDIT: I realize that Q3 is probably because of (broad-)yaml's implicit boolean conversions. Is it possible to disable those, so that |
If you are using this library, please post a note here and let me know if you have any luck or any questions....
The text was updated successfully, but these errors were encountered: