-
Notifications
You must be signed in to change notification settings - Fork 0
PTHMINT-84: Fix field/method type inconsistency #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #34 +/- ##
==========================================
- Coverage 90.53% 90.23% -0.30%
==========================================
Files 107 107
Lines 2334 2355 +21
==========================================
+ Hits 2113 2125 +12
- Misses 221 230 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the robustness of request model classes by making method parameters optional throughout the codebase. The changes add defensive None checks to prevent runtime errors when optional data is missing, update type annotations to reflect optional parameters, and improve return type clarity for methods that may return None.
Key changes:
- Updated method parameter types from required to Optional across multiple request model classes
- Added None checks before accessing object methods to prevent AttributeErrors
- Updated return type annotations to reflect optional return values where applicable
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test_integration_orders_components_checkout_options.py | Updated test to verify None is returned instead of raising AttributeError when shopping cart is None |
| delivery.py | Added None checks before calling get methods on country, phone, and email objects |
| customer.py | Made locale, IP address, forwarded IP, referrer, user agent, and reference parameters optional with None guards |
| tax_rule.py | Made tax rule parameter optional and added early return for None values |
| checkout_options.py | Made tax_tables and shopping_cart parameters optional with None guards |
| shopping_cart.py | Made items and item parameters optional with None checks in add methods |
| order_request.py | Made all add method parameters optional across order type, currency, amount, and other fields |
| meta.py | Made birthday, bank account, phone, email, and gender parameters optional with None guards |
| destination_holder.py | Made name, city, country, IBAN, and SWIFT parameters optional with None checks |
| creditcard.py | Made card holder name, expiry date, CVC, and term URL parameters optional |
| account.py | Made account ID, holder name, holder IBAN, and emandate parameters optional with None guards |
| checkout_options.py (components) | Made tax_tables parameter optional and added None check for shopping_cart |
| refund_request.py | Made currency, amount, description, and checkout_data parameters optional with None guards |
| checkout_data.py | Made items parameter optional, updated return types to Optional, and added comprehensive None checks |
| capture_request.py | Made amount and all string parameters optional across capture request methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request improves the robustness and flexibility of several request model classes by making many method parameters optional, updating type annotations, and adding defensive checks for None values. These changes help prevent errors when optional data is missing and clarify the expected usage of these APIs.
Key changes include:
Type annotation and parameter updates:
CaptureOrderRequest,RefundOrderRequest,CheckoutData,CheckoutOptions, andAccountto acceptOptionaltypes instead of requiring values. This allows these methods to handle cases where some fields may not be provided. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21]Defensive programming and None handling:
.get()or iterating over lists) to prevent runtime errors. For example, in methods likeadd_amount,add_item, andgenerate_from_shopping_cart, the code now safely handles missing or None inputs. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Return type improvements:
get_itemsandget_iteminCheckoutDatato returnOptionalvalues, making it clear that these methods may return None if no data is present. [1] [2]Error handling enhancements:
CheckoutData). [1] [2]These changes make the codebase more resilient and easier to use in situations where not all information is available upfront.