Skip to content

Commit a01e5bd

Browse files
committed
Add v2.6.0
1 parent 53b55a4 commit a01e5bd

30 files changed

Lines changed: 71 additions & 127 deletions

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.1.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-ast
66
- id: fix-byte-order-marker
@@ -14,7 +14,7 @@ repos:
1414
- id: trailing-whitespace
1515

1616
- repo: https://github.com/psf/black
17-
rev: 22.3.0
17+
rev: 24.2.0
1818
hooks:
1919
- id: black
2020

@@ -27,23 +27,23 @@ repos:
2727
types: [python]
2828

2929
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
30-
rev: v1.0.5
30+
rev: v1.0.6
3131
hooks:
3232
- id: python-bandit-vulnerability-check
3333
args: [--skip, "B101", --recursive, clumper]
3434

3535
- repo: https://github.com/pypa/pip-audit
36-
rev: v2.4.4
36+
rev: v2.7.2
3737
hooks:
3838
- id: pip-audit
3939
args: ["-r", "requirements.txt"]
4040

4141
- repo: https://github.com/asottile/pyupgrade
42-
rev: v2.29.0
42+
rev: v3.15.0
4343
hooks:
4444
- id: pyupgrade
4545
args: [--py311-plus]
4646
- repo: https://github.com/jorisroovers/gitlint
47-
rev: v0.16.0
47+
rev: v0.19.1
4848
hooks:
4949
- id: gitlint

core_client/__init__.py

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
import jwt
66
from datetime import datetime
77
from httpx import InvalidURL as HttpInvalidURL, HTTPError
8-
from pydantic import (
9-
HttpUrl,
10-
ValidationError as PydanticValidationError,
11-
validate_call
12-
)
8+
from pydantic import HttpUrl, ValidationError as PydanticValidationError, validate_call
139

1410
from . import base
1511
from .models import Client as ClientModel
@@ -115,15 +111,10 @@ def _access_token_is_expired(self):
115111
return True
116112
if not self.access_token_expires_at:
117113
try:
118-
self._set_access_token_expires_at(
119-
Token(access_token=self.access_token)
120-
)
114+
self._set_access_token_expires_at(Token(access_token=self.access_token))
121115
except (PydanticValidationError, TypeError, HTTPError):
122116
return True
123-
if (
124-
datetime.fromtimestamp(self.access_token_expires_at)
125-
> datetime.now()
126-
):
117+
if datetime.fromtimestamp(self.access_token_expires_at) > datetime.now():
127118
return False
128119
return True
129120

@@ -149,15 +140,10 @@ def _refresh_token_is_expired(self):
149140
return True
150141
if not self.refresh_token_expires_at:
151142
try:
152-
self._set_refresh_token_expires_at(
153-
Token(refresh_token=self.refresh_token)
154-
)
143+
self._set_refresh_token_expires_at(Token(refresh_token=self.refresh_token))
155144
except (PydanticValidationError, TypeError, HTTPError):
156145
return True
157-
if (
158-
datetime.fromtimestamp(self.refresh_token_expires_at)
159-
> datetime.now()
160-
):
146+
if datetime.fromtimestamp(self.refresh_token_expires_at) > datetime.now():
161147
return False
162148
return True
163149

@@ -182,8 +168,7 @@ def _refresh_access_token(self):
182168

183169
def _get_headers(self):
184170
_headers = self.headers.copy()
185-
if (self.username and self.password) or \
186-
self.access_token or self.refresh_token or self.auth0_token:
171+
if (self.username and self.password) or self.access_token or self.refresh_token or self.auth0_token:
187172
if (
188173
self.refresh_token
189174
and self._refresh_token_is_expired() is False
@@ -226,21 +211,15 @@ def login(self):
226211
elif self.username and self.password:
227212
self._basic_login()
228213
return self.token()
229-
elif (
230-
self.access_token
231-
and not self.refresh_token
232-
and not (self.username and self.password)
233-
):
214+
elif self.access_token and not self.refresh_token and not (self.username and self.password):
234215
try:
235216
response = Token(access_token=self.access_token)
236217
self._set_access_token_expires_at(response)
237218
return response
238219
except (PydanticValidationError, TypeError):
239220
return Token()
240221
elif (
241-
not self.access_token
242-
and not self.refresh_token
243-
and not (self.username and self.password)
222+
not self.access_token and not self.refresh_token and not (self.username and self.password)
244223
):
245224
return Token()
246225
else:
@@ -295,12 +274,10 @@ async def proxy_method(self, *args, **kwargs):
295274
for submodule_info in pkgutil.walk_packages(path=module.__path__, prefix=sub_prefix):
296275
submodule = importlib.import_module(submodule_info.name)
297276
if hasattr(submodule, "asyncio"):
298-
method_name = submodule_info.name.split('.')[-1]
299-
AsyncClient._add_proxy_method(
300-
method_name, submodule.asyncio
301-
)
277+
method_name = submodule_info.name.split(".")[-1]
278+
AsyncClient._add_proxy_method(method_name, submodule.asyncio)
302279
if hasattr(submodule, "sync"):
303-
method_name = submodule_info.name.split('.')[-1]
280+
method_name = submodule_info.name.split(".")[-1]
304281
Client._add_proxy_method(method_name, submodule.sync)
305282

306283
except Exception as e:

core_client/base/api/v3_cluster_iam_delete_user.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ def _build_request(
3333

3434
def _build_response(response: httpx.Response):
3535
if response.status_code == 200:
36-
if (
37-
response.headers["content-type"]
38-
== "application/json; charset=UTF-8"
39-
):
36+
if response.headers["content-type"] == "application/json; charset=UTF-8":
4037
response_200 = response.json()
4138
else:
4239
response_200 = response.text

core_client/base/api/v3_cluster_iam_get_reload.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ def _build_request(
2727

2828
def _build_response(response: httpx.Response):
2929
if response.status_code == 200:
30-
if (
31-
response.headers["content-type"]
32-
== "application/json; charset=UTF-8"
33-
):
30+
if response.headers["content-type"] == "application/json; charset=UTF-8":
3431
response_200 = response.json()
3532
else:
3633
response_200 = response.text

core_client/base/api/v3_cluster_node_fs_delete_file.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def _build_request(
3030

3131
def _build_response(response: httpx.Response):
3232
if response.status_code == 200:
33-
if (
34-
response.headers["content-type"]
35-
== "application/json; charset=UTF-8"
36-
):
33+
if response.headers["content-type"] == "application/json; charset=UTF-8":
3734
response_200 = response.json()
3835
else:
3936
response_200 = response.text

core_client/base/api/v3_cluster_node_fs_put_file.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def _build_response(response: httpx.Response):
3333
if response.status_code == 200:
3434
if (
3535
"content-type" in response.headers
36-
and response.headers["content-type"]
37-
== "application/json; charset=UTF-8"
36+
and response.headers["content-type"] == "application/json; charset=UTF-8"
3837
):
3938
response_200 = response.json()
4039
else:
@@ -43,8 +42,7 @@ def _build_response(response: httpx.Response):
4342
elif response.status_code == 201:
4443
if (
4544
"content-type" in response.headers
46-
and response.headers["content-type"]
47-
== "application/json; charset=UTF-8"
45+
and response.headers["content-type"] == "application/json; charset=UTF-8"
4846
):
4947
response_201 = response.json()
5048
else:
@@ -53,8 +51,7 @@ def _build_response(response: httpx.Response):
5351
elif response.status_code == 204:
5452
if (
5553
"content-type" in response.headers
56-
and response.headers["content-type"]
57-
== "application/json; charset=UTF-8"
54+
and response.headers["content-type"] == "application/json; charset=UTF-8"
5855
):
5956
response_204 = response.json()
6057
else:

core_client/base/api/v3_cluster_node_get_process_list.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88

99
@validate_call()
10-
def _build_request(
11-
client: Client, id: str, retries: int = None, timeout: float = None
12-
):
10+
def _build_request(client: Client, id: str, retries: int = None, timeout: float = None):
1311
if not retries:
1412
retries = client.retries
1513
if not timeout:

core_client/base/api/v3_cluster_node_get_version.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88

99
@validate_call()
10-
def _build_request(
11-
client: Client, id: str, retries: int = None, timeout: float = None
12-
):
10+
def _build_request(client: Client, id: str, retries: int = None, timeout: float = None):
1311
if not retries:
1412
retries = client.retries
1513
if not timeout:

core_client/base/api/v3_cluster_put_leave.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ def _build_request(
3131

3232
def _build_response(response: httpx.Response):
3333
if response.status_code == 200:
34-
if (
35-
response.headers["content-type"]
36-
== "application/json; charset=UTF-8"
37-
):
34+
if response.headers["content-type"] == "application/json; charset=UTF-8":
3835
response_200 = response.json()
3936
else:
4037
response_200 = response.text

core_client/base/api/v3_config_reload.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ def _build_request(
2727

2828
def _build_response(response: httpx.Response):
2929
if response.status_code == 200:
30-
if (
31-
response.headers["content-type"]
32-
== "application/json; charset=UTF-8"
33-
):
30+
if response.headers["content-type"] == "application/json; charset=UTF-8":
3431
response_200 = response.json()
3532
else:
3633
response_200 = response.text

0 commit comments

Comments
 (0)