Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ extend-safe-fixes = [
"D415", # docstrings should end with a period, question mark, or exclamation point
]
ignore = [
"ANN401",
"ARG002",
"B006",
"B904",
Expand Down
4 changes: 2 additions & 2 deletions src/multisafepay/api/base/response/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See the DISCLAIMER.md file for disclaimer details.


from typing import Any, Optional
from typing import Optional, Union

from multisafepay.api.base.listings.pager import Pager
from multisafepay.model.extra_model import ExtraModel
Expand Down Expand Up @@ -65,7 +65,7 @@ def with_json(
raw=json_data.__str__(),
)

def get_body_data(self: "ApiResponse") -> Optional[Any]:
def get_body_data(self: "ApiResponse") -> Optional[Union[dict, list]]:
"""
Get the data from the body of the response.

Expand Down
8 changes: 4 additions & 4 deletions src/multisafepay/api/base/response/custom_api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# See the DISCLAIMER.md file for disclaimer details.

from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Union

from multisafepay.api.base.response.api_response import ApiResponse

Expand All @@ -20,11 +20,11 @@ class CustomApiResponse(ApiResponse):

"""

data: Optional[Any]
data: Optional[Union[dict, list]]

def __init__(
self: "CustomApiResponse",
data: Optional[Any],
data: Optional[Union[dict, list]],
**kwargs: Dict[str, Any],
) -> None:
"""
Expand All @@ -41,7 +41,7 @@ def __init__(
for key, value in kwargs.items():
setattr(self, key, value)

def get_data(self: "CustomApiResponse") -> Optional[Any]:
def get_data(self: "CustomApiResponse") -> Optional[Union[dict, list]]:
"""
Get the data contained in the response.

Expand Down
10 changes: 7 additions & 3 deletions src/multisafepay/exception/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


import json
from typing import Any
from typing import Dict, List, Optional, Union


class ApiException(Exception):
Expand Down Expand Up @@ -115,7 +115,10 @@ def get_context_as_array(self: "ApiException") -> list:
lines.append(f"{context_name}: {debug_value}")
return lines

def get_context_value(self: "ApiException", name: str) -> Any:
def get_context_value(
self: "ApiException",
name: str,
) -> Optional[Union[str, int, float, bool, Dict, List]]:
"""
Get a specific context value by name.

Expand All @@ -125,7 +128,8 @@ def get_context_value(self: "ApiException", name: str) -> Any:

Returns
-------
The value associated with the given name, or None if the name is not found.
Optional[Union[str, int, float, bool, Dict, List]]: The value associated with the given name,
or None if the name is not found.

"""
return self.context.get(name)
6 changes: 3 additions & 3 deletions src/multisafepay/util/dict_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# See the DISCLAIMER.md file for disclaimer details.

from typing import Any, Optional
from typing import Optional


def merge_recursive(dict1: dict, dict2: dict) -> dict:
Expand Down Expand Up @@ -66,7 +66,7 @@ def remove_null_recursive(input_data: dict) -> dict:

"""

def process_value(value: Any) -> Optional[Any]:
def process_value(value: object) -> Optional[object]:
if isinstance(value, dict):
processed_dict = remove_null_recursive(value)
return processed_dict if processed_dict else None
Expand All @@ -85,7 +85,7 @@ def process_value(value: Any) -> Optional[Any]:
}


def dict_empty(value: Any) -> bool:
def dict_empty(value: object) -> bool:
"""
Check if the given value is an empty dictionary.

Expand Down
5 changes: 2 additions & 3 deletions src/multisafepay/util/total_amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


import json
from typing import Any

from multisafepay.exception.invalid_total_amount import (
InvalidTotalAmountException,
Expand Down Expand Up @@ -74,7 +73,7 @@ def __calculate_totals(data: dict) -> float:
def __get_tax_rate_by_item(
item: dict,
data: dict,
) -> Any:
) -> object:
"""
Get the tax rate for a specific item in the shopping cart.

Expand All @@ -85,7 +84,7 @@ def __get_tax_rate_by_item(

Returns
-------
int | List[int | Any] | Any: The tax rate for the item, or 0 if no tax rate is found.
object: The tax rate for the item, or 0 if no tax rate is found.

"""
if "tax_table_selector" not in item or not item["tax_table_selector"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
# See the DISCLAIMER.md file for disclaimer details.


from typing import Any

from multisafepay.api.base.listings.listing_pager import ListingPager
from multisafepay.api.base.listings.pager import Pager
from multisafepay.api.base.listings.cursor import Cursor


class MockItem:
def __init__(self: "MockItem", value: Any) -> None:
def __init__(self: "MockItem", value: object) -> None:
"""
Initialize a MockItem with a given value.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

# See the DISCLAIMER.md file for disclaimer details.

from typing import Any

from multisafepay.api.base.listings.listing import Listing


class MockItem:
def __init__(self: "MockItem", value: Any) -> None:
def __init__(self: "MockItem", value: object) -> None:
self.value = value


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

# See the DISCLAIMER.md file for disclaimer details.

from typing import Any

from multisafepay.api.base.listings.listing_pager import ListingPager


class MockItem:
def __init__(self: "MockItem", value: Any) -> None:
def __init__(self: "MockItem", value: object) -> None:
"""
Initialize a MockItem with a given value.

Expand Down