fhir-py icon indicating copy to clipboard operation
fhir-py copied to clipboard

Unable to use items() on AttrDict

Open ruscoder opened this issue 2 years ago • 2 comments

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 avatar Aug 11 '23 15:08 ruscoder

@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 avatar Aug 11 '23 15:08 ruscoder

Similar issues caused by attr access: #59

ruscoder avatar Aug 11 '23 15:08 ruscoder