From 8c3ee8525c8902001dce0db2bc1f0a2b7f77a22d Mon Sep 17 00:00:00 2001 From: halcy Date: Fri, 14 Feb 2025 21:01:56 +0200 Subject: [PATCH] Document entities, fix minor oversight on suggestions endpoint --- CHANGELOG.rst | 1 + docs/02_return_values.rst | 3 +++ mastodon/suggestions.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 487b766..fd3398e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,7 @@ v2.0.0 (IN PROGRESS) * Fix library not working with -O2 (Thanks mirabilos for the report) * Version check mode now defaults to "none", since it keeps causing more problems than it solves. * Document `media` (Thanks LunarLambda for the report) +* Added json serialization and deserialization for returned entities v1.8.1 ------ diff --git a/docs/02_return_values.rst b/docs/02_return_values.rst index 1baa758..036bb66 100644 --- a/docs/02_return_values.rst +++ b/docs/02_return_values.rst @@ -30,6 +30,9 @@ the AttribAccessDict - this means that you can still access all returned values attributes, `even if a type does not define them.`. Lists have been split into lists that can be paginated (i.e. that have pagination attributes) and those that cannot. +All return values can be converted from and to JSON using the `to_json()` and `from_json()` +methods defined on the ::class::`mastodon.types_base.Entity` class. + Base types ========== .. autoclass:: mastodon.types_base.AttribAccessDict diff --git a/mastodon/suggestions.py b/mastodon/suggestions.py index 71d27c5..800e923 100644 --- a/mastodon/suggestions.py +++ b/mastodon/suggestions.py @@ -25,7 +25,7 @@ class Mastodon(Internals): """ return self.__api_request('GET', '/api/v2/suggestions') - def suggestions(self) -> NonPaginatableList[Account]: + def suggestions(self) -> Union[NonPaginatableList[Suggestion], NonPaginatableList[Account]]: """ Fetch follow suggestions for the logged-in user.