Skip to content

Commit 9dccc4f

Browse files
committed
PTHMINT-47: Fix ruff ANN401
1 parent 782365b commit 9dccc4f

File tree

9 files changed

+21
-23
lines changed

9 files changed

+21
-23
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-
"ANN401",
102101
"ARG002",
103102
"B006",
104103
"B904",

src/multisafepay/api/base/response/api_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See the DISCLAIMER.md file for disclaimer details.
77

88

9-
from typing import Any, Optional
9+
from typing import Optional, Union
1010

1111
from multisafepay.api.base.listings.pager import Pager
1212
from multisafepay.model.extra_model import ExtraModel
@@ -65,7 +65,7 @@ def with_json(
6565
raw=json_data.__str__(),
6666
)
6767

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

src/multisafepay/api/base/response/custom_api_response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# See the DISCLAIMER.md file for disclaimer details.
77

8-
from typing import Any, Dict, Optional
8+
from typing import Any, Dict, Optional, Union
99

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

@@ -20,11 +20,11 @@ class CustomApiResponse(ApiResponse):
2020
2121
"""
2222

23-
data: Optional[Any]
23+
data: Optional[Union[dict, list]]
2424

2525
def __init__(
2626
self: "CustomApiResponse",
27-
data: Optional[Any],
27+
data: Optional[Union[dict, list]],
2828
**kwargs: Dict[str, Any],
2929
) -> None:
3030
"""
@@ -41,7 +41,7 @@ def __init__(
4141
for key, value in kwargs.items():
4242
setattr(self, key, value)
4343

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

src/multisafepay/exception/api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
import json
10-
from typing import Any
10+
from typing import Dict, List, Optional, Union
1111

1212

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

118-
def get_context_value(self: "ApiException", name: str) -> Any:
118+
def get_context_value(
119+
self: "ApiException",
120+
name: str,
121+
) -> Optional[Union[str, int, float, bool, Dict, List]]:
119122
"""
120123
Get a specific context value by name.
121124
@@ -125,7 +128,8 @@ def get_context_value(self: "ApiException", name: str) -> Any:
125128
126129
Returns
127130
-------
128-
The value associated with the given name, or None if the name is not found.
131+
Optional[Union[str, int, float, bool, Dict, List]]: The value associated with the given name,
132+
or None if the name is not found.
129133
130134
"""
131135
return self.context.get(name)

src/multisafepay/util/dict_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# See the DISCLAIMER.md file for disclaimer details.
77

8-
from typing import Any, Optional
8+
from typing import Optional
99

1010

1111
def merge_recursive(dict1: dict, dict2: dict) -> dict:
@@ -66,7 +66,7 @@ def remove_null_recursive(input_data: dict) -> dict:
6666
6767
"""
6868

69-
def process_value(value: Any) -> Optional[Any]:
69+
def process_value(value: object) -> Optional[object]:
7070
if isinstance(value, dict):
7171
processed_dict = remove_null_recursive(value)
7272
return processed_dict if processed_dict else None
@@ -85,7 +85,7 @@ def process_value(value: Any) -> Optional[Any]:
8585
}
8686

8787

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

src/multisafepay/util/total_amount.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
import json
10-
from typing import Any
1110

1211
from multisafepay.exception.invalid_total_amount import (
1312
InvalidTotalAmountException,
@@ -74,7 +73,7 @@ def __calculate_totals(data: dict) -> float:
7473
def __get_tax_rate_by_item(
7574
item: dict,
7675
data: dict,
77-
) -> Any:
76+
) -> object:
7877
"""
7978
Get the tax rate for a specific item in the shopping cart.
8079
@@ -85,7 +84,7 @@ def __get_tax_rate_by_item(
8584
8685
Returns
8786
-------
88-
int | List[int | Any] | Any: The tax rate for the item, or 0 if no tax rate is found.
87+
object: The tax rate for the item, or 0 if no tax rate is found.
8988
9089
"""
9190
if "tax_table_selector" not in item or not item["tax_table_selector"]:

tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
# See the DISCLAIMER.md file for disclaimer details.
77

88

9-
from typing import Any
10-
119
from multisafepay.api.base.listings.listing_pager import ListingPager
1210
from multisafepay.api.base.listings.pager import Pager
1311
from multisafepay.api.base.listings.cursor import Cursor
1412

1513

1614
class MockItem:
17-
def __init__(self: "MockItem", value: Any) -> None:
15+
def __init__(self: "MockItem", value: object) -> None:
1816
"""
1917
Initialize a MockItem with a given value.
2018

tests/multisafepay/unit/api/base/listings/test_unit_listing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55

66
# See the DISCLAIMER.md file for disclaimer details.
77

8-
from typing import Any
98

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

1211

1312
class MockItem:
14-
def __init__(self: "MockItem", value: Any) -> None:
13+
def __init__(self: "MockItem", value: object) -> None:
1514
self.value = value
1615

1716

tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55

66
# See the DISCLAIMER.md file for disclaimer details.
77

8-
from typing import Any
98

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

1211

1312
class MockItem:
14-
def __init__(self: "MockItem", value: Any) -> None:
13+
def __init__(self: "MockItem", value: object) -> None:
1514
"""
1615
Initialize a MockItem with a given value.
1716

0 commit comments

Comments
 (0)