Conversation
Migrate typing annotations to built-in generics (list, dict, etc.) and tidy imports across the codebase for Python 3.9+ compatibility. Updated various modules to replace typing.List/Dict/Type/Iterator with modern equivalents, adjusted some Optional and Union hints, and simplified imports. Added [tool.ruff] target-version = "py39" to pyproject.toml. Also tightened tests: assert recurring_id presence and use identity check for boolean in an assertion.
There was a problem hiding this comment.
Pull request overview
This PR modernizes type annotations by migrating from typing module generics (List, Dict, Type, Iterator) to PEP 585 built-in generics (list, dict, type) and collections.abc.Iterator, enabling Python 3.9+ compatibility. The changes improve code maintainability by using modern Python type hint syntax. Additionally, test assertions are strengthened to verify the presence of recurring_id and use identity checks for boolean comparisons.
Changes:
- Replaced
typing.List,typing.Dict,typing.Typewith built-inlist,dict,typeacross 14 files - Migrated
typing.Iteratortocollections.abc.Iteratorin 2 files - Added
target-version = "py39"to pyproject.toml Ruff configuration - Enhanced test assertions for recurring_id presence and boolean identity checks
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added Ruff target-version configuration for Python 3.9 |
| tests/multisafepay/e2e/examples/recurring_manager/test_recurring.py | Added recurring_id assertion and improved boolean comparison |
| src/multisafepay/value_object/decimal_amount.py | Updated Type to type in validator |
| src/multisafepay/util/message.py | Replaced List/Dict with list/dict, Iterator from collections.abc |
| src/multisafepay/util/address_parser.py | Replaced List with list |
| src/multisafepay/exception/api.py | Replaced Dict/List with dict/list |
| src/multisafepay/client/client.py | Replaced Dict with dict, added Optional for context param |
| src/multisafepay/api/shared/checkout/tax_rule.py | Replaced List/Dict with list/dict |
| src/multisafepay/api/shared/checkout/checkout_options.py | Replaced List with list |
| src/multisafepay/api/shared/cart/shopping_cart.py | Replaced List with list |
| src/multisafepay/api/paths/transactions/response/transaction.py | Replaced List with list |
| src/multisafepay/api/paths/payment_methods/response/payment_method.py | Replaced List with list |
| src/multisafepay/api/paths/payment_methods/response/components/brand.py | Replaced List with list |
| src/multisafepay/api/paths/orders/response/order_response.py | Replaced List with list |
| src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py | Replaced List with list |
| src/multisafepay/api/base/response/custom_api_response.py | Replaced Dict with dict |
| src/multisafepay/api/base/listings/listing.py | Replaced List/Dict/Iterator with list/dict/collections.abc.Iterator |
| src/multisafepay/api/base/decorator.py | Replaced Dict/List with dict/list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pyproject.toml
Outdated
| [tool.ruff] | ||
| target-version = "py39" |
There was a problem hiding this comment.
The [tool.ruff] section should be placed before [tool.ruff.lint] section. In TOML files, parent sections should come before their subsections for better organization and clarity. Consider moving the [tool.ruff] section to line 96 (before [tool.ruff.lint]).
| @validator("amount", pre=True) | ||
| def convert_to_decimal( | ||
| cls: Type["DecimalAmount"], | ||
| cls: type["DecimalAmount"], |
There was a problem hiding this comment.
The validator parameter type annotation is inconsistent with other validators in the codebase. All other validators use cls: "ClassName" (e.g., cls: "ApiKey" in api_key.py, cls: "Country" in country.py), but this one uses cls: type["DecimalAmount"]. For consistency with Pydantic validator patterns and the rest of the codebase, this should be cls: "DecimalAmount".
| cls: type["DecimalAmount"], | |
| cls: "DecimalAmount", |
Update pyproject.toml to require pylint ^3.3.0 and regenerate poetry.lock (Poetry 2.2.1) to lock the updated dependencies. This ensures dev tooling uses the newer pylint release and related dependency constraints are refreshed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46 +/- ##
=======================================
Coverage 90.62% 90.62%
=======================================
Files 144 144
Lines 2539 2539
=======================================
Hits 2301 2301
Misses 238 238 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Move and consolidate the [tool.ruff] block in pyproject.toml (add target-version = "py39" and remove duplicate section). Update DecimalAmount.validator signature to use a string forward reference for cls ("DecimalAmount") instead of type[...] to avoid typing/forward-reference issues on Python 3.9 and keep annotations consistet.
Migrate typing annotations to built-in generics (list, dict, etc.) and tidy imports across the codebase for Python 3.9+ compatibility. Updated various modules to replace typing.List/Dict/Type/Iterator with modern equivalents, adjusted some Optional and Union hints, and simplified imports. Added [tool.ruff] target-version = "py39" to pyproject.toml. Also tightened tests: assert recurring_id presence and use identity check for boolean in an assertion.