From 834a5a7fe2b4ca989d18c145caeaf78ed78e3956 Mon Sep 17 00:00:00 2001 From: Vftdan Date: Mon, 1 Jul 2024 15:52:42 +0200 Subject: [PATCH] Fix codestyle & typehint --- mastoposter/sources.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mastoposter/sources.py b/mastoposter/sources.py index f3a23b2..5352804 100644 --- a/mastoposter/sources.py +++ b/mastoposter/sources.py @@ -69,14 +69,16 @@ async def websocket_source( async def single_status_source( - status_url: str, url: str = None, access_token: str = None, retries: int = 5, **kwargs + status_url: str, url: str = None, access_token: str = None, + retries: int = 5, **kwargs ) -> AsyncGenerator[Status, None]: # TODO: catch exceptions from httpx import Client, HTTPTransport user_authority = urlparse(url).netloc if url is not None else None try: - status_url = f"https://{user_authority}/api/v1/statuses/{int(status_url)}" + status_url = \ + f"https://{user_authority}/api/v1/statuses/{int(status_url)}" except ValueError: pass parsed_status_url = urlparse(status_url) @@ -101,7 +103,8 @@ async def single_status_source( ) status = Status.from_dict(rq.json()) else: - search_instance = user_authority if user_authority is not None else parsed_status_url.netloc + search_instance = user_authority if user_authority is not None \ + else parsed_status_url.netloc if search_instance != user_authority: access_token = None @@ -115,7 +118,7 @@ async def single_status_source( f"https://{search_instance}/api/v2/search", params=params, ) - statuses: List[Status] = rq.json().get("statuses", []) + statuses: List[dict] = rq.json().get("statuses", []) if len(statuses) < 1: logger.error("Instance %s hasn't found status %r", search_instance, status_url)