Skip to content
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

Unable to use items() on AttrDict #110

Open
ruscoder opened this issue Aug 11, 2023 · 2 comments
Open

Unable to use items() on AttrDict #110

ruscoder opened this issue Aug 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ruscoder
Copy link
Member

ruscoder commented Aug 11, 2023

original = {"nested": {"items": {}}}

original.items() # => dict_items([('nested', {'items': {}})])

client.resource("CustomResource", **original).serialize().items() # => TypeError: 'AttrDict' object is not callable
client.resource("CustomResource", **original)['nested'].items() # => TypeError: 'AttrDict' object is not callable

And the most important case, it's impossible save this resource because it makes serialize() and then json.dumps()

client.resource("CustomResource", **original).save() # => TypeError
@ruscoder
Copy link
Member Author

ruscoder commented Aug 11, 2023

@ir4y the root of the issue is attr access via dot.
Personally, I don't like this approach, dict must have dict behavior.

But it's too late to get rid of it. We need to find a workaround, at least, serialize() should return pure dict instead of AttrDict

@ruscoder
Copy link
Member Author

Similar issues caused by attr access: #59

@ruscoder ruscoder added the bug Something isn't working label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant