Skip to content

Commit 372ff27

Browse files
committed
Apply B rule
1 parent e676a58 commit 372ff27

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ select = [
5454
"F",
5555
"I",
5656
"UP",
57-
# "B",
57+
"B",
5858
]
5959
exclude = ["tdclient/test/*"]
6060
ignore = ["E203", "E501"]

tdclient/api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ def post(
314314
urllib3.exceptions.PoolError,
315315
):
316316
if not self._retry_post_requests:
317-
raise APIError("Retrying stopped by retry_post_requests == False")
317+
raise APIError(
318+
"Retrying stopped by retry_post_requests == False"
319+
) from None
318320

319321
if cumul_retry_delay <= self._max_cumul_retry_delay:
320322
log.warning(
@@ -402,7 +404,7 @@ def put(
402404
urllib3.exceptions.TimeoutError,
403405
urllib3.exceptions.PoolError,
404406
):
405-
raise APIError(f"Error: {repr(response)}")
407+
raise APIError(f"Error: {repr(response)}") from None
406408

407409
log.debug(
408410
"REST PUT response:\n headers: %s\n status: %d\n body: <omitted>",
@@ -570,7 +572,7 @@ def checked_json(self, body: bytes, required: list[str]) -> dict[str, Any]:
570572
try:
571573
js = json.loads(body.decode("utf-8"))
572574
except ValueError as error:
573-
raise APIError(f"Unexpected API response: {error}: {repr(body)}")
575+
raise APIError(f"Unexpected API response: {error}: {repr(body)}") from error
574576
js = dict(js)
575577
if 0 < [k in js for k in required].count(False):
576578
missing = [k for k in required if k not in js]

tdclient/job_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def update(self) -> None:
112112
def _update_status(self) -> None:
113113
warnings.warn(
114114
"_update_status() will be removed from future release. Please use update() instaed.",
115+
stacklevel=2,
115116
category=DeprecationWarning,
116117
)
117118
self.update()

tdclient/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def validate_record(record: Record) -> bool:
4343
if not any(k in record for k in ("time", b"time")):
4444
warnings.warn(
4545
'records should have "time" column to import records properly.',
46+
stacklevel=2,
4647
category=RuntimeWarning,
4748
)
4849
return True
@@ -132,7 +133,7 @@ def merge_dtypes_and_converters(
132133
"Unrecognized dtype {!r}, must be one of {}".format(
133134
dtype, ", ".join(repr(k) for k in sorted(DTYPE_TO_CALLABLE))
134135
)
135-
)
136+
) from None
136137
if converters is not None:
137138
for column_name, parse_fn in converters.items():
138139
our_converters[column_name] = parse_fn

0 commit comments

Comments
 (0)