Skip to content

Commit 3d7504d

Browse files
MHHukiewitzhoh
authored andcommitted
prevent unnecessary .as_http_params() call
1 parent 3fc2a17 commit 3d7504d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Diff for: src/aleph/sdk/client/client.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,14 @@ async def get_posts(
284284
)
285285

286286
if not post_filter:
287-
post_filter = PostFilter()
288-
params = post_filter.as_http_params()
289-
params["page"] = str(page)
290-
params["pagination"] = str(page_size)
287+
params = {
288+
"page": str(page),
289+
"pagination": str(page_size),
290+
}
291+
else:
292+
params = post_filter.as_http_params()
293+
params["page"] = str(page)
294+
params["pagination"] = str(page_size)
291295

292296
async with self.http_session.get("/api/v0/posts.json", params=params) as resp:
293297
resp.raise_for_status()
@@ -408,10 +412,15 @@ async def get_messages(
408412
)
409413

410414
if not message_filter:
411-
message_filter = MessageFilter()
412-
params = message_filter.as_http_params()
413-
params["page"] = str(page)
414-
params["pagination"] = str(page_size)
415+
params = {
416+
"page": str(page),
417+
"pagination": str(page_size),
418+
}
419+
else:
420+
params = message_filter.as_http_params()
421+
params["page"] = str(page)
422+
params["pagination"] = str(page_size)
423+
415424
async with self.http_session.get(
416425
"/api/v0/messages.json", params=params
417426
) as resp:
@@ -479,8 +488,7 @@ async def watch_messages(
479488
self,
480489
message_filter: Optional[MessageFilter] = None,
481490
) -> AsyncIterable[AlephMessage]:
482-
if not message_filter:
483-
message_filter = MessageFilter()
491+
message_filter = message_filter or MessageFilter()
484492
params = message_filter.as_http_params()
485493

486494
async with self.http_session.ws_connect(

0 commit comments

Comments
 (0)