Skip to content

Commit c9fdd1e

Browse files
refactor: write rest client
1 parent 9e20507 commit c9fdd1e

3 files changed

Lines changed: 4 additions & 11 deletions

File tree

influxdb_client_3/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,12 @@ def __init__(
305305
# TODO fix retries
306306
retries = None
307307

308-
self.base_url = f"{scheme}://{hostname}:{port}"
309-
310-
# TODO refactor
311308
auth_schema = 'Token' if auth_scheme is None else auth_scheme
312309
default_header = {
313310
'Authorization': f'{auth_schema} {self._token}',
314311
'User-Agent': USER_AGENT
315312
}
313+
self.base_url = f"{scheme}://{hostname}:{port}"
316314
self.default_header = default_header
317315
self.rest_client = rest.RestClient(
318316
base_url=self.base_url,
@@ -706,10 +704,9 @@ def get_server_version(self) -> Any | None:
706704
if key.lower() == "x-influxdb-version":
707705
return value
708706

709-
# TODO refactor this
710-
string = resp.get_string_body()
711-
if string is not None:
712-
return json.loads(string)['version']
707+
string_body = resp.get_string_body()
708+
if string_body is not None:
709+
return json.loads(string_body)['version']
713710
return None
714711

715712
def flush(self):

influxdb_client_3/write_client/_sync/rest_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def getheader(self, name, default=None):
3232
"""Return a given response header."""
3333
return self.urllib3_response.headers.get(name, default)
3434

35-
# TODO is this the best way?
3635
def get_string_body(self):
3736
string = self.urllib3_response.data.decode('utf-8')
3837
if string is None or string == '':

influxdb_client_3/write_client/client/write_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@
7070

7171
"""Commons function for Sync and Async client."""
7272

73-
# TODO should this file be refactored and remove?
7473
try:
75-
# import dataclasses
76-
7774
_HAS_DATACLASS = True
7875
except ModuleNotFoundError:
7976
_HAS_DATACLASS = False

0 commit comments

Comments
 (0)