Skip to content

Commit 5cf2359

Browse files
committed
Use enum value for 'listing_type' in api calls
The bug in the API calls for listing comments and posts within the 'lemmylib' library has been fixed. The 'type_' parameter key was previously incorrectly expecting the entire 'listing_type' enum instance, but it now correctly expects the 'value' attribute of the 'listing_type' enum instance.
1 parent 86e2d0a commit 5cf2359

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lemmylib/lib.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,15 @@ def list_comments(self, page: int = 1, post_id: int | None = None, sort: LemmyPo
201201
if post_id is None and community_id is None and community_name is None and user_id is None and user_name is None:
202202
raise Exception("LemmyLib: Either post_id, community_id, community_name, user_id or user_name must be set")
203203

204-
return self.call_api(LemmyApiMethod.GET, f'comments', params={'page': page, 'post_id': post_id, 'sort': sort,
205-
'type_': listing_type.value,
206-
'parent_id': parent_id,
207-
'community_id': community_id,
208-
'community_name': community_name,
209-
'user_id': user_id,
210-
'user_name': user_name,
211-
'saved_only': saved_only})
204+
return self.call_api(LemmyApiMethod.GET, f'comments',
205+
params={'page': page, 'post_id': post_id, 'sort': sort.value,
206+
'type_': listing_type.value,
207+
'parent_id': parent_id,
208+
'community_id': community_id,
209+
'community_name': community_name,
210+
'user_id': user_id,
211+
'user_name': user_name,
212+
'saved_only': saved_only})
212213

213214
def list_posts(self,
214215
page: int | None = None, page_cursor: int | None = None, sort: LemmyPostSort = None,
@@ -219,7 +220,7 @@ def list_posts(self,
219220
self._logger.debug("LemmyLib list_posts")
220221

221222
return self.call_api(LemmyApiMethod.GET, f'posts',
222-
params={'page_cursor': page_cursor, 'sort': sort, 'type_': listing_type.value,
223+
params={'page_cursor': page_cursor, 'sort': sort.value, 'type_': listing_type.value,
223224
'community_id': community_id,
224225
'page': page,
225226
'community_name': community_name,

0 commit comments

Comments
 (0)