-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
As I've been using this library, I've bitten myself a couple times expecting a specific response type that I was not given. I wonder if it would make sense to use Python dataclasses to help constrain response data-structures into a predictable format, making it easier to program against the Lychee API.
What do you think?
Example
@dataclass
class PhotoData:
some_attribute: str
another_attr: int
...
def get_photo(self, photo_id) -> dict:
"""Get information about a photo."""
data = {'photoID': photo_id}
response = self._session.post('Photo::get', json=data)
response.raise_for_status() # Raises an error if an unexpected HTTP response is returned
return PhotoData(**response.json())Metadata
Metadata
Assignees
Labels
No labels