-
Notifications
You must be signed in to change notification settings - Fork 10
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
Create an Object with fields as arguments #79
Comments
I don't intend to add support for keyword arguments as the fields. Is there anything this prevents you from doing? If you replace Instance conversion to a dictionary is a different story - if you could open a separate issue for that I would be grateful. |
Yeah, this is what I am doing for now, I create my object this way
which is basically the same as you propose, it works but I found it less convenient as using arguments, especially for nested objects. I find this easier to instantiate to avoid errors at runtime and sport them with a linter:
than this:
|
Regarding the conversion to a dictionary it's anyway not an issue for now as converting a dict to json is fairly easy :-) since the Object is anyway created from a dict already. |
I'm afraid even if the arguments were keyword arguments, I still don't think a linter could detect an issue there. If you can suggest a way to do that, I would certainly consider it. The problem is signalling to a linter/static type checker:
And all of the other variations supported by the JSON Schema spec. |
I agree with you it's an easy task, I'm not able to provide a solution here. |
It would be nice to be able to instantiate a model with some fields the same way a dataclass can be created and be able to use it to output a JSON dict.
The text was updated successfully, but these errors were encountered: