Skip to content

Commit e688730

Browse files
committed
PTHMINT-94: Fix lint and tests failed
1 parent 2443c01 commit e688730

29 files changed

Lines changed: 347 additions & 209 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,6 @@ ignore = [
139139
"TRY300",
140140
]
141141
select = ["ALL"]
142+
143+
[tool.ruff]
144+
target-version = "py39"

src/multisafepay/api/base/decorator.py

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

88
"""Decorator class for response model transformations and dependencies."""
99

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

1212

1313
class Decorator:
@@ -20,9 +20,9 @@ class Decorator:
2020
2121
"""
2222

23-
dependencies: Optional[Dict]
23+
dependencies: Optional[dict]
2424

25-
def __init__(self: "Decorator", dependencies: Dict = None) -> None:
25+
def __init__(self: "Decorator", dependencies: dict = None) -> None:
2626
"""
2727
Initialize the Decorator with optional dependencies.
2828
@@ -35,7 +35,7 @@ def __init__(self: "Decorator", dependencies: Dict = None) -> None:
3535

3636
def adapt_checkout_options(
3737
self: "Decorator",
38-
checkout_options: Optional[Dict],
38+
checkout_options: Optional[dict],
3939
) -> "Decorator":
4040
"""
4141
Adapt the checkout options and update the dependencies.
@@ -59,7 +59,7 @@ def adapt_checkout_options(
5959
)
6060
return self
6161

62-
def adapt_costs(self: "Decorator", costs: Optional[Dict]) -> "Decorator":
62+
def adapt_costs(self: "Decorator", costs: Optional[dict]) -> "Decorator":
6363
"""
6464
Adapt the costs and update the dependencies.
6565
@@ -82,7 +82,7 @@ def adapt_costs(self: "Decorator", costs: Optional[Dict]) -> "Decorator":
8282

8383
def adapt_custom_info(
8484
self: "Decorator",
85-
custom_info: Optional[Dict],
85+
custom_info: Optional[dict],
8686
) -> "Decorator":
8787
"""
8888
Adapt the custom information and update the dependencies.
@@ -107,7 +107,7 @@ def adapt_custom_info(
107107

108108
def adapt_customer(
109109
self: "Decorator",
110-
customer: Optional[Dict],
110+
customer: Optional[dict],
111111
) -> "Decorator":
112112
"""
113113
Adapt the customer information and update the dependencies.
@@ -130,7 +130,7 @@ def adapt_customer(
130130

131131
def adapt_order_adjustment(
132132
self: "Decorator",
133-
order_adjustment: Optional[Dict],
133+
order_adjustment: Optional[dict],
134134
) -> "Decorator":
135135
"""
136136
Adapt the order adjustment and update the dependencies.
@@ -157,7 +157,7 @@ def adapt_order_adjustment(
157157

158158
def adapt_payment_details(
159159
self: "Decorator",
160-
payment_details: Optional[Dict],
160+
payment_details: Optional[dict],
161161
) -> "Decorator":
162162
"""
163163
Adapt the payment details and update the dependencies.
@@ -184,7 +184,7 @@ def adapt_payment_details(
184184

185185
def adapt_payment_methods(
186186
self: "Decorator",
187-
payment_methods: Optional[Dict],
187+
payment_methods: Optional[dict],
188188
) -> "Decorator":
189189
"""
190190
Adapt the payment methods and update the dependencies.
@@ -209,7 +209,7 @@ def adapt_payment_methods(
209209

210210
def adapt_shopping_cart(
211211
self: "Decorator",
212-
shopping_cart: Optional[Dict],
212+
shopping_cart: Optional[dict],
213213
) -> "Decorator":
214214
"""
215215
Adapt the shopping cart and update the dependencies.
@@ -233,7 +233,7 @@ def adapt_shopping_cart(
233233

234234
def adapt_related_transactions(
235235
self: "Decorator",
236-
related_transactions: Optional[Dict],
236+
related_transactions: Optional[dict],
237237
) -> "Decorator":
238238
"""
239239
Adapt the related transactions and update the dependencies.
@@ -258,7 +258,7 @@ def adapt_related_transactions(
258258
]
259259
return self
260260

261-
def adapt_apps(self: "Decorator", apps: Optional[Dict]) -> "Decorator":
261+
def adapt_apps(self: "Decorator", apps: Optional[dict]) -> "Decorator":
262262
"""
263263
Adapt the apps and update the dependencies.
264264
@@ -282,7 +282,7 @@ def adapt_apps(self: "Decorator", apps: Optional[Dict]) -> "Decorator":
282282

283283
def adapt_brands(
284284
self: "Decorator",
285-
brands: Optional[List[Optional[Dict]]],
285+
brands: Optional[list[Optional[dict]]],
286286
) -> "Decorator":
287287
"""
288288
Adapt the brands and update the dependencies.
@@ -308,7 +308,7 @@ def adapt_brands(
308308

309309
def adapt_icon_urls(
310310
self: "Decorator",
311-
icon_urls: Optional[Dict],
311+
icon_urls: Optional[dict],
312312
) -> "Decorator":
313313
"""
314314
Adapt the icon URLs and update the dependencies.
@@ -333,7 +333,7 @@ def adapt_icon_urls(
333333

334334
def adapt_tokenization(
335335
self: "Decorator",
336-
tokenization: Optional[Dict],
336+
tokenization: Optional[dict],
337337
) -> "Decorator":
338338
"""
339339
Adapt the tokenization and update the dependencies.
@@ -360,7 +360,7 @@ def adapt_tokenization(
360360

361361
def adapt_allowed_amount(
362362
self: "Decorator",
363-
allowed_amount: Optional[Dict],
363+
allowed_amount: Optional[dict],
364364
) -> "Decorator":
365365
"""
366366
Adapt the allowed amount and update the dependencies.
@@ -384,7 +384,7 @@ def adapt_allowed_amount(
384384
)
385385
return self
386386

387-
def get_dependencies(self: "Decorator") -> Dict[str, Any]:
387+
def get_dependencies(self: "Decorator") -> dict[str, Any]:
388388
"""
389389
Get the current dependencies.
390390

src/multisafepay/api/base/listings/listing.py

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

88
"""Generic listing container for API response collections."""
99

10-
from typing import Any, Dict, Generic, Iterator, List, TypeVar
10+
from collections.abc import Iterator
11+
from typing import Any, Generic, TypeVar
1112

1213
from pydantic.main import BaseModel
1314

@@ -24,13 +25,13 @@ class Listing(Generic[T], BaseModel):
2425
2526
"""
2627

27-
data: List[T]
28+
data: list[T]
2829

2930
def __init__(
3031
self: "Listing",
31-
data: List[Any],
32+
data: list[Any],
3233
class_type: type,
33-
**kwargs: Dict[str, Any],
34+
**kwargs: dict[str, Any],
3435
) -> None:
3536
"""
3637
Initialize the Listing with data and a class type.
@@ -42,7 +43,7 @@ def __init__(
4243
**kwargs: Additional keyword arguments to pass to the class type constructor.
4344
4445
"""
45-
elements: List[T] = []
46+
elements: list[T] = []
4647
if data:
4748
for item_data in data:
4849
if item_data:
@@ -92,7 +93,7 @@ def __len__(self: "Listing") -> int:
9293
"""
9394
return len(self.data)
9495

95-
def get_data(self: "Listing") -> List[T]:
96+
def get_data(self: "Listing") -> list[T]:
9697
"""
9798
Get the list of items in the listing.
9899

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

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

88
"""Custom API response class with generic typing support for flexible response handling."""
99

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

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

@@ -27,7 +27,7 @@ class CustomApiResponse(ApiResponse):
2727
def __init__(
2828
self: "CustomApiResponse",
2929
data: Optional[Union[dict, list]],
30-
**kwargs: Dict[str, Any],
30+
**kwargs: dict[str, Any],
3131
) -> None:
3232
"""
3333
Initialize the CustomApiResponse with optional data and additional keyword arguments.

src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py

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

88
"""Checkout data model for refund request checkout information and configuration."""
99

10-
from typing import List, Optional
10+
from typing import Optional
1111

1212
from multisafepay.api.shared.cart.cart_item import CartItem
1313
from multisafepay.api.shared.cart.shopping_cart import ShoppingCart
@@ -25,11 +25,11 @@ class CheckoutData(RequestModel):
2525
2626
"""
2727

28-
items: Optional[List[CartItem]]
28+
items: Optional[list[CartItem]]
2929

3030
def add_items(
3131
self: "CheckoutData",
32-
items: Optional[List[CartItem]] = None,
32+
items: Optional[list[CartItem]] = None,
3333
) -> "CheckoutData":
3434
"""
3535
Adds multiple items to the checkout data.
@@ -74,7 +74,7 @@ def add_item(
7474
self.items.append(item)
7575
return self
7676

77-
def get_items(self: "CheckoutData") -> Optional[List[CartItem]]:
77+
def get_items(self: "CheckoutData") -> Optional[list[CartItem]]:
7878
"""
7979
Retrieves all items from the checkout data.
8080

src/multisafepay/api/paths/orders/response/order_response.py

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

88
"""Order response models for handling order API responses and data structures."""
99

10-
from typing import List, Optional
10+
from typing import Optional
1111

1212
from multisafepay.api.base.decorator import Decorator
1313
from multisafepay.api.paths.orders.response.components.order_adjustment import (
@@ -74,7 +74,7 @@ class Order(ResponseModel):
7474
amount: Optional[int]
7575
amount_refunded: Optional[int]
7676
checkout_options: Optional[CheckoutOptions]
77-
costs: Optional[List[Costs]]
77+
costs: Optional[list[Costs]]
7878
created: Optional[str]
7979
modified: Optional[str]
8080
currency: Optional[str]
@@ -88,10 +88,10 @@ class Order(ResponseModel):
8888
order_id: Optional[str]
8989
order_total: Optional[float]
9090
payment_details: Optional[PaymentDetails]
91-
payment_methods: Optional[List[PaymentMethod]]
91+
payment_methods: Optional[list[PaymentMethod]]
9292
reason: Optional[str]
9393
reason_code: Optional[str]
94-
related_transactions: Optional[List[Transaction]]
94+
related_transactions: Optional[list[Transaction]]
9595
shopping_cart: Optional[ShoppingCart]
9696
status: Optional[str]
9797
transaction_id: Optional[str]

src/multisafepay/api/paths/payment_methods/response/components/brand.py

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

88
"""Brand model for payment method branding information and display settings."""
99

10-
from typing import List, Optional
10+
from typing import Optional
1111

1212
from multisafepay.api.paths.payment_methods.response.components.icon_urls import (
1313
IconUrls,
@@ -28,7 +28,7 @@ class Brand(ResponseModel):
2828
2929
"""
3030

31-
allowed_countries: Optional[List[str]]
31+
allowed_countries: Optional[list[str]]
3232
icon_urls: Optional[IconUrls]
3333
id: Optional[str]
3434
name: Optional[str]

src/multisafepay/api/paths/payment_methods/response/payment_method.py

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

88
"""Payment method response model for handling payment method configurations and options."""
99

10-
from typing import List, Optional
10+
from typing import Optional
1111

1212
from multisafepay.api.base.decorator import Decorator
1313
from multisafepay.api.paths.payment_methods.response.components.allowed_amount import (
@@ -55,17 +55,17 @@ class PaymentMethod(ResponseModel):
5555

5656
additional_data: Optional[dict]
5757
allowed_amount: Optional[AllowedAmount]
58-
allowed_countries: Optional[List[str]]
59-
allowed_currencies: Optional[List[str]]
58+
allowed_countries: Optional[list[str]]
59+
allowed_currencies: Optional[list[str]]
6060
apps: Optional[Apps]
61-
brands: Optional[List[Brand]]
61+
brands: Optional[list[Brand]]
6262
description: Optional[str]
6363
icon_urls: Optional[IconUrls]
6464
id: Optional[str]
6565
label: Optional[str]
6666
name: Optional[str]
67-
preferred_countries: Optional[List[str]]
68-
required_customer_data: Optional[List[str]]
67+
preferred_countries: Optional[list[str]]
68+
required_customer_data: Optional[list[str]]
6969
tokenization: Optional[Tokenization]
7070
type: Optional[str]
7171
shopping_cart_required: Optional[bool]

src/multisafepay/api/paths/transactions/response/transaction.py

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

88
"""Transaction response model for handling transaction data and status information."""
99

10-
from typing import List, Optional
10+
from typing import Optional
1111

1212
from multisafepay.api.base.decorator import Decorator
1313
from multisafepay.api.shared.costs import Costs
@@ -55,7 +55,7 @@ class Transaction(ResponseModel):
5555

5656
amount: Optional[int]
5757
completed: Optional[str]
58-
costs: Optional[List[Costs]]
58+
costs: Optional[list[Costs]]
5959
created: Optional[str]
6060
modified: Optional[str]
6161
currency: Optional[str]
@@ -68,7 +68,7 @@ class Transaction(ResponseModel):
6868
net: Optional[int]
6969
order_id: Optional[str]
7070
payment_method: Optional[str]
71-
payment_methods: Optional[List[PaymentMethod]]
71+
payment_methods: Optional[list[PaymentMethod]]
7272
reason: Optional[str]
7373
reason_code: Optional[str]
7474
site_id: Optional[str]

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

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

88
"""Shopping cart model for managing cart items in order processing."""
99

10-
from typing import List, Optional
10+
from typing import Optional
1111

1212
from multisafepay.api.shared.cart.cart_item import CartItem
1313
from multisafepay.model.api_model import ApiModel
@@ -23,9 +23,9 @@ class ShoppingCart(ApiModel):
2323
2424
"""
2525

26-
items: Optional[List[CartItem]]
26+
items: Optional[list[CartItem]]
2727

28-
def get_items(self: "ShoppingCart") -> Optional[List[CartItem]]:
28+
def get_items(self: "ShoppingCart") -> Optional[list[CartItem]]:
2929
"""
3030
Get the list of items in the shopping cart.
3131
@@ -38,7 +38,7 @@ def get_items(self: "ShoppingCart") -> Optional[List[CartItem]]:
3838

3939
def add_items(
4040
self: "ShoppingCart",
41-
items: Optional[List[CartItem]],
41+
items: Optional[list[CartItem]],
4242
) -> "ShoppingCart":
4343
"""
4444
Add multiple items to the shopping cart.

0 commit comments

Comments
 (0)