-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[python-experimental] implement in
operator for model classes
#7637
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. This looks great!
@spacether relevant question - is there value in raising an exception instead of returning code i want to simplify is this:
with default
thoughts? |
In my opinion there is value. Attributes can be nullable which is different than being unset. |
If you want this functionality why not add a default missing input argument to a get method in ModelNormal and ModelComposd? That would make it work like python dict.get. Why not use model._data_store.get(name)? |
we definitely can differentiate in both cases via exception or by using
yes, that's another method i want to add, but it would be nice if using attributes directly was more convenient. right now i have to wrap in try/except way too much :(
i don't think all attributes are in there? required attributes seem to be in model.__dict__ directly. |
The attribute that are not in _data_store are data about the class or the composed instance. |
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master
Allow to check for attribute presence in model using
in
operator.Unless I'm missing something, right now the only way to correctly get an attribute which may not be present is this:
which is quite cumbersome.
@spacether