Skip to content

Commit 670996a

Browse files
committed
PTHMINT-50: Fix ruff B904
1 parent fdcbfeb commit 670996a

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ extend-safe-fixes = [
9898
"D415", # docstrings should end with a period, question mark, or exclamation point
9999
]
100100
ignore = [
101-
"B904",
102101
"BLE001",
103102
"D100",
104103
"D101",

src/multisafepay/api/shared/cart/cart_item.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ def add_tax_rate_percentage(
280280

281281
try:
282282
self.tax_table_selector = str(tax_rate_percentage / 100)
283-
except (ValueError, TypeError):
283+
except (ValueError, TypeError) as e:
284284
raise InvalidArgumentException(
285285
"Tax rate percentage cannot be converted to a string.",
286-
)
286+
) from e
287287

288288
return self
289289

@@ -316,10 +316,10 @@ def add_tax_rate(self: "CartItem", tax_rate: float) -> "CartItem":
316316

317317
try:
318318
self.tax_table_selector = str(tax_rate)
319-
except (ValueError, TypeError):
319+
except (ValueError, TypeError) as e:
320320
raise InvalidArgumentException(
321321
"Tax rate cannot be converted to a string.",
322-
)
322+
) from e
323323

324324
return self
325325

src/multisafepay/client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _create_request(
246246
response.raise_for_status()
247247
except RequestException as e:
248248
if 500 <= response.status_code < 600:
249-
raise ApiException(f"Request failed: {e}")
249+
raise ApiException(f"Request failed: {e}") from e
250250

251251
context = context or {}
252252
context.update(

src/multisafepay/util/webhook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def validate(
6060
transaction_json,
6161
separators=(",", ":"),
6262
)
63-
except json.JSONDecodeError:
63+
except json.JSONDecodeError as e:
6464
raise InvalidArgumentException(
6565
"Request must be a valid JSON string",
66-
)
66+
) from e
6767

6868
if validation_time_in_seconds < 0:
6969
raise InvalidArgumentException(

src/multisafepay/value_object/date.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def __init__(self: "Date", date: str) -> None:
4545
else:
4646
timestamp = datetime.strptime(date, "%Y-%m-%d").timestamp()
4747
super().__init__(timestamp=timestamp, str_date=date)
48-
except ValueError:
48+
except ValueError as e:
4949
raise InvalidArgumentException(
5050
f'Value "{date}" is an invalid date format',
51-
)
51+
) from e
5252

5353
def get(self: "Date", date_format: str = "%Y-%m-%d") -> str:
5454
"""

0 commit comments

Comments
 (0)