-
Notifications
You must be signed in to change notification settings - Fork 48
Implemented nested dict re-cast #174
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
Implemented nested dict re-cast #174
Conversation
I just realized, I never came across any CFN resource that would have patternProperties 🤔 |
Thank you for your contribution. CFN open source team will take a look at the pull request and provide an update. There are some resources that use |
So 3 I didnt use so far! Bummer Do let me know if this passes your tests and requirements :) |
Hey @ammokhov |
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.
this looks good to me but still subject to integ testing
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.
I pulled these changes and did some manual integration testing. LGTM.
We'll have to add some kind of CLA integration for future PRs, but for now, can you simply respond to this issue with this text to confirm you give us the right to include your contribution to our code base?
License for reference. |
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. |
Related to #172
When trying to recast dict items, if the key is not found, it will iterate over the "nested" dict items first.
At first, I had
which works fine. However, then the recast_test would not pass as the type for
json_data[k][_child]
would be that ofcls
instead of more "primitive" ones.Drawback to that is that in the handlers code, every object is a
dict
instead of being of typecls
. which means no access to the object attributes directly.Welcome for suggestions on how to keep the typing in handlers when using
model
instead of having to deal in puredict
Edit 1:
For the record, for the purpose of handlers, casting the nested value to the correct class, then use it and return to CFN works totally fine. In my CFN resource type I left the code as follows
And everything works totally fine.