Skip to content
Snippets Groups Projects
Commit 04a581ff authored by Vincent Texier's avatar Vincent Texier
Browse files

[enh] #91 fix pylint alerts in api.client module

parent 3195ca05
No related branches found
No related tags found
1 merge request!65Pylint
...@@ -85,7 +85,7 @@ async def parse_response(response: ClientResponse, schema: dict) -> Any: ...@@ -85,7 +85,7 @@ async def parse_response(response: ClientResponse, schema: dict) -> Any:
raise jsonschema.ValidationError("Could not parse json : {0}".format(str(e))) raise jsonschema.ValidationError("Could not parse json : {0}".format(str(e)))
class API(object): class API:
""" """
API is a class used as an abstraction layer over the request library (AIOHTTP). API is a class used as an abstraction layer over the request library (AIOHTTP).
""" """
...@@ -131,7 +131,7 @@ class API(object): ...@@ -131,7 +131,7 @@ class API(object):
:param path: the request path :param path: the request path
:return: :return:
""" """
logging.debug("Request : {0}".format(self.reverse_url(self.connection_handler.http_scheme, path))) logging.debug("Request : %s", self.reverse_url(self.connection_handler.http_scheme, path))
url = self.reverse_url(self.connection_handler.http_scheme, path) url = self.reverse_url(self.connection_handler.http_scheme, path)
response = await self.connection_handler.session.get(url, params=kwargs, headers=self.headers, response = await self.connection_handler.session.get(url, params=kwargs, headers=self.headers,
proxy=self.connection_handler.proxy, proxy=self.connection_handler.proxy,
...@@ -155,7 +155,7 @@ class API(object): ...@@ -155,7 +155,7 @@ class API(object):
if 'self_' in kwargs: if 'self_' in kwargs:
kwargs['self'] = kwargs.pop('self_') kwargs['self'] = kwargs.pop('self_')
logging.debug("POST : {0}".format(kwargs)) logging.debug("POST : %s", kwargs)
response = await self.connection_handler.session.post( response = await self.connection_handler.session.post(
self.reverse_url(self.connection_handler.http_scheme, path), self.reverse_url(self.connection_handler.http_scheme, path),
data=kwargs, data=kwargs,
...@@ -236,12 +236,12 @@ class Client: ...@@ -236,12 +236,12 @@ class Client:
await parse_response(response, schema) await parse_response(response, schema)
# return the chosen type # return the chosen type
if rtype == RESPONSE_AIOHTTP: if rtype == RESPONSE_TEXT:
return response response = await response.text()
elif rtype == RESPONSE_TEXT:
return await response.text()
elif rtype == RESPONSE_JSON: elif rtype == RESPONSE_JSON:
return await response.json() response = await response.json()
return response
async def post(self, url_path: str, params: dict = None, rtype: str = RESPONSE_JSON, schema: dict = None) -> Any: async def post(self, url_path: str, params: dict = None, rtype: str = RESPONSE_JSON, schema: dict = None) -> Any:
""" """
...@@ -267,12 +267,12 @@ class Client: ...@@ -267,12 +267,12 @@ class Client:
await parse_response(response, schema) await parse_response(response, schema)
# return the chosen type # return the chosen type
if rtype == RESPONSE_AIOHTTP: if rtype == RESPONSE_TEXT:
return response response = await response.text()
elif rtype == RESPONSE_TEXT:
return await response.text()
elif rtype == RESPONSE_JSON: elif rtype == RESPONSE_JSON:
return await response.json() response = await response.json()
return response
def connect_ws(self, path: str) -> _WSRequestContextManager: def connect_ws(self, path: str) -> _WSRequestContextManager:
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment