Skip to content

Commit c38bab7

Browse files
authored
Merge pull request #16 from solvedac/http-client
Remove Singleton pattern from HTTP client
2 parents da0ef00 + 8e229a3 commit c38bab7

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

solvedac_community/HTTPClients/abstract_http_client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121

2222
class AbstractHTTPClient(metaclass=ABCMeta):
23-
def __new__(cls, *args, **kwargs):
24-
if not hasattr(cls, "_instance"):
25-
cls._instance = super().__new__(cls)
26-
return cls._instance
2723

2824
@abstractmethod
2925
def __init__(self):

solvedac_community/HTTPClients/aiohttp_client.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
class AiohttpHTTPClient(AbstractHTTPClient):
2727
USER_AGENT: ClassVar[str] = "Mozilla/5.0"
2828

29-
def __new__(cls, *args, **kwargs):
30-
if not hasattr(cls, "_instance"):
31-
cls._instance = super().__new__(cls)
32-
return cls._instance
33-
3429
def __init__(self, loop: asyncio.AbstractEventLoop, solvedac_token: Optional[str] = None) -> None:
3530
self.loop: asyncio.AbstractEventLoop = loop
3631
self.session: aiohttp.ClientSession = MISSING

solvedac_community/HTTPClients/httpclient.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ def __make_url(url: str, params: dict) -> str:
8787
def __init__(self, method: RequestMethod, url: str, params: Optional[Dict[str, Any]] = None) -> None:
8888
if params:
8989
url = self.__make_url(url, params)
90-
(self.url): str = self.BASE_URL + url
91-
(self.method): RequestMethod = method
90+
self.url: str = self.BASE_URL + url
91+
self.method: RequestMethod = method
9292

9393

9494
class ResponseData:
9595
def __init__(self, text: str, status: int) -> None:
96-
(self.response_data): str = text
97-
(self.status): int = status
96+
self.response_data: str = text
97+
self.status: int = status
9898

9999
def __str__(self) -> str:
100100
return f"status_code : {self.status}\nresponse_data : {self.response_data}"

solvedac_community/HTTPClients/httpx_client.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
class HttpxHTTPClient(AbstractHTTPClient):
2626
USER_AGENT: ClassVar[str] = "Mozilla/5.0"
2727

28-
def __new__(cls, *args, **kwargs):
29-
if not hasattr(cls, "_instance"):
30-
cls._instance = super().__new__(cls)
31-
return cls._instance
32-
3328
def __init__(self, loop: asyncio.AbstractEventLoop, solvedac_token: Optional[str] = None) -> None:
3429
self.loop: asyncio.AbstractEventLoop = loop
3530
self.lock: asyncio.Lock = asyncio.Lock()

0 commit comments

Comments
 (0)