beda-software / fhir-py

FHIR Client for python
MIT License
168 stars 31 forks source link

Unable to use items() on AttrDict #110

Open ruscoder opened 1 year ago

ruscoder commented 1 year ago
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 commented 1 year ago

@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 commented 1 year ago

Similar issues caused by attr access: #59