diff --git a/pyproject.toml b/pyproject.toml index ab1f67c..1c51ec8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,6 @@ extend-safe-fixes = [ "D415", # docstrings should end with a period, question mark, or exclamation point ] ignore = [ - "B904", "BLE001", "D100", "D101", diff --git a/src/multisafepay/api/shared/cart/cart_item.py b/src/multisafepay/api/shared/cart/cart_item.py index 67fe880..0d4984e 100644 --- a/src/multisafepay/api/shared/cart/cart_item.py +++ b/src/multisafepay/api/shared/cart/cart_item.py @@ -280,10 +280,10 @@ def add_tax_rate_percentage( try: self.tax_table_selector = str(tax_rate_percentage / 100) - except (ValueError, TypeError): + except (ValueError, TypeError) as e: raise InvalidArgumentException( "Tax rate percentage cannot be converted to a string.", - ) + ) from e return self @@ -316,10 +316,10 @@ def add_tax_rate(self: "CartItem", tax_rate: float) -> "CartItem": try: self.tax_table_selector = str(tax_rate) - except (ValueError, TypeError): + except (ValueError, TypeError) as e: raise InvalidArgumentException( "Tax rate cannot be converted to a string.", - ) + ) from e return self diff --git a/src/multisafepay/client/client.py b/src/multisafepay/client/client.py index ee5047e..ab5a741 100644 --- a/src/multisafepay/client/client.py +++ b/src/multisafepay/client/client.py @@ -246,7 +246,7 @@ def _create_request( response.raise_for_status() except RequestException as e: if 500 <= response.status_code < 600: - raise ApiException(f"Request failed: {e}") + raise ApiException(f"Request failed: {e}") from e context = context or {} context.update( diff --git a/src/multisafepay/util/webhook.py b/src/multisafepay/util/webhook.py index 719a90d..1c3834a 100644 --- a/src/multisafepay/util/webhook.py +++ b/src/multisafepay/util/webhook.py @@ -60,10 +60,10 @@ def validate( transaction_json, separators=(",", ":"), ) - except json.JSONDecodeError: + except json.JSONDecodeError as e: raise InvalidArgumentException( "Request must be a valid JSON string", - ) + ) from e if validation_time_in_seconds < 0: raise InvalidArgumentException( diff --git a/src/multisafepay/value_object/date.py b/src/multisafepay/value_object/date.py index a6c2eee..a11f42c 100644 --- a/src/multisafepay/value_object/date.py +++ b/src/multisafepay/value_object/date.py @@ -45,10 +45,10 @@ def __init__(self: "Date", date: str) -> None: else: timestamp = datetime.strptime(date, "%Y-%m-%d").timestamp() super().__init__(timestamp=timestamp, str_date=date) - except ValueError: + except ValueError as e: raise InvalidArgumentException( f'Value "{date}" is an invalid date format', - ) + ) from e def get(self: "Date", date_format: str = "%Y-%m-%d") -> str: """