From f52af80012d8ec0195d5386b622729edee7f564c Mon Sep 17 00:00:00 2001 From: DevRuby <60344644+dev-ruby@users.noreply.github.com> Date: Fri, 16 Jun 2023 18:05:25 +0900 Subject: [PATCH 1/2] refactor: Remove unnecessary parentheses --- solvedac_community/HTTPClients/httpclient.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/solvedac_community/HTTPClients/httpclient.py b/solvedac_community/HTTPClients/httpclient.py index 76c0c62..7b89b8d 100644 --- a/solvedac_community/HTTPClients/httpclient.py +++ b/solvedac_community/HTTPClients/httpclient.py @@ -87,14 +87,14 @@ def __make_url(url: str, params: dict) -> str: def __init__(self, method: RequestMethod, url: str, params: Optional[Dict[str, Any]] = None) -> None: if params: url = self.__make_url(url, params) - (self.url): str = self.BASE_URL + url - (self.method): RequestMethod = method + self.url: str = self.BASE_URL + url + self.method: RequestMethod = method class ResponseData: def __init__(self, text: str, status: int) -> None: - (self.response_data): str = text - (self.status): int = status + self.response_data: str = text + self.status: int = status def __str__(self) -> str: return f"status_code : {self.status}\nresponse_data : {self.response_data}" From 8e229a38ec3efecb43e73323ea8d13fe805882f4 Mon Sep 17 00:00:00 2001 From: DevRuby <60344644+dev-ruby@users.noreply.github.com> Date: Fri, 16 Jun 2023 18:08:52 +0900 Subject: [PATCH 2/2] refactor: Remove Singleton pattern from HTTP client --- solvedac_community/HTTPClients/abstract_http_client.py | 4 ---- solvedac_community/HTTPClients/aiohttp_client.py | 5 ----- solvedac_community/HTTPClients/httpx_client.py | 5 ----- 3 files changed, 14 deletions(-) diff --git a/solvedac_community/HTTPClients/abstract_http_client.py b/solvedac_community/HTTPClients/abstract_http_client.py index 864ac53..8b51725 100644 --- a/solvedac_community/HTTPClients/abstract_http_client.py +++ b/solvedac_community/HTTPClients/abstract_http_client.py @@ -20,10 +20,6 @@ class AbstractHTTPClient(metaclass=ABCMeta): - def __new__(cls, *args, **kwargs): - if not hasattr(cls, "_instance"): - cls._instance = super().__new__(cls) - return cls._instance @abstractmethod def __init__(self): diff --git a/solvedac_community/HTTPClients/aiohttp_client.py b/solvedac_community/HTTPClients/aiohttp_client.py index b0abb88..765ab1f 100644 --- a/solvedac_community/HTTPClients/aiohttp_client.py +++ b/solvedac_community/HTTPClients/aiohttp_client.py @@ -26,11 +26,6 @@ class AiohttpHTTPClient(AbstractHTTPClient): USER_AGENT: ClassVar[str] = "Mozilla/5.0" - def __new__(cls, *args, **kwargs): - if not hasattr(cls, "_instance"): - cls._instance = super().__new__(cls) - return cls._instance - def __init__(self, loop: asyncio.AbstractEventLoop, solvedac_token: Optional[str] = None) -> None: self.loop: asyncio.AbstractEventLoop = loop self.session: aiohttp.ClientSession = MISSING diff --git a/solvedac_community/HTTPClients/httpx_client.py b/solvedac_community/HTTPClients/httpx_client.py index 42e602a..7295f3d 100644 --- a/solvedac_community/HTTPClients/httpx_client.py +++ b/solvedac_community/HTTPClients/httpx_client.py @@ -25,11 +25,6 @@ class HttpxHTTPClient(AbstractHTTPClient): USER_AGENT: ClassVar[str] = "Mozilla/5.0" - def __new__(cls, *args, **kwargs): - if not hasattr(cls, "_instance"): - cls._instance = super().__new__(cls) - return cls._instance - def __init__(self, loop: asyncio.AbstractEventLoop, solvedac_token: Optional[str] = None) -> None: self.loop: asyncio.AbstractEventLoop = loop self.lock: asyncio.Lock = asyncio.Lock()