MarshalX / atproto

The AT Protocol (🦋 Bluesky) SDK for Python 🐍
https://atproto.blue
MIT License
314 stars 33 forks source link

Add deserialization of records in responses #3

Closed MarshalX closed 1 year ago

MarshalX commented 1 year ago

Now the records in the responses are plain dicts. We need to parse it as Record Models. The models are generated already.

It doesn't work now because in the lexicons all records are marked as "unknown" instead of the reference to the record model.

For now this fields are typehinted as "Any": https://github.com/MarshalX/atproto/blob/0826a31a3668eec9d85f79c3e9861ed394ab1165/atproto/codegen/models/generator.py#L156C1-L158

MarshalX commented 1 year ago

if the record could has any amount of custom fields, well, let's keep it as dict. Typehint probably could be dict too?

image
MarshalX commented 1 year ago

well, if the SDK can't find the proper model to parse some complex type it will fall back to dict. also, the ability to access to model's fields by [] was added. to have the ability to use the same syntax for both cases