from attr import attrib, attrs @attrs class Vendors: apple = attrib(type=bool) spotify = attrib(type=bool) @attrs class UserSettings: markets = attrib(type=list) vendors = attrib(converter=lambda kv: Vendors(**kv)) notifications = attrib(type=bool) @attrs class UserSettingsGetResponse: id = attrib() data = attrib(converter=lambda x: UserSettings(**x)) account_id = attrib() default = attrib(default=None, converter=lambda x: UserSettings(**x) if x else None)