diff --git a/pyproject.toml b/pyproject.toml index c0b8250..617d303 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 = [ - "ANN401", "ARG002", "B006", "B904", diff --git a/src/multisafepay/api/base/response/api_response.py b/src/multisafepay/api/base/response/api_response.py index 2980c15..8b30a4f 100644 --- a/src/multisafepay/api/base/response/api_response.py +++ b/src/multisafepay/api/base/response/api_response.py @@ -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 @@ -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. diff --git a/src/multisafepay/api/base/response/custom_api_response.py b/src/multisafepay/api/base/response/custom_api_response.py index 0a9398d..7a0bad6 100644 --- a/src/multisafepay/api/base/response/custom_api_response.py +++ b/src/multisafepay/api/base/response/custom_api_response.py @@ -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 @@ -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: """ @@ -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. diff --git a/src/multisafepay/exception/api.py b/src/multisafepay/exception/api.py index 34706df..b4b799a 100644 --- a/src/multisafepay/exception/api.py +++ b/src/multisafepay/exception/api.py @@ -7,7 +7,7 @@ import json -from typing import Any +from typing import Dict, List, Optional, Union class ApiException(Exception): @@ -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. @@ -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) diff --git a/src/multisafepay/util/dict_utils.py b/src/multisafepay/util/dict_utils.py index 2d4092c..555ec59 100644 --- a/src/multisafepay/util/dict_utils.py +++ b/src/multisafepay/util/dict_utils.py @@ -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: @@ -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 @@ -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. diff --git a/src/multisafepay/util/total_amount.py b/src/multisafepay/util/total_amount.py index e8f8edd..09286aa 100644 --- a/src/multisafepay/util/total_amount.py +++ b/src/multisafepay/util/total_amount.py @@ -7,7 +7,6 @@ import json -from typing import Any from multisafepay.exception.invalid_total_amount import ( InvalidTotalAmountException, @@ -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. @@ -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"]: diff --git a/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py b/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py index 60304ed..00d4caf 100644 --- a/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py +++ b/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py @@ -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. diff --git a/tests/multisafepay/unit/api/base/listings/test_unit_listing.py b/tests/multisafepay/unit/api/base/listings/test_unit_listing.py index ad6f7d5..8461120 100644 --- a/tests/multisafepay/unit/api/base/listings/test_unit_listing.py +++ b/tests/multisafepay/unit/api/base/listings/test_unit_listing.py @@ -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 diff --git a/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py b/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py index 844c54d..28a0877 100644 --- a/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py +++ b/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py @@ -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.