Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented Nov 18, 2025

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:

Defensive programming and None handling:

  • Added checks for None values before performing operations (like calling .get() or iterating over lists) to prevent runtime errors. For example, in methods like add_amount, add_item, and generate_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:

  • Updated return types for methods like get_items and get_item in CheckoutData to return Optional values, making it clear that these methods may return None if no data is present. [1] [2]

Error handling enhancements:

  • Improved error messages and checks in methods that access items in lists, raising exceptions if required data is missing (e.g., when no items are present in CheckoutData). [1] [2]

These changes make the codebase more resilient and easier to use in situations where not all information is available upfront.

@zulquer zulquer requested a review from danielcivit November 18, 2025 15:17
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.23%. Comparing base (c7afd53) to head (da522fe).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielcivit danielcivit requested a review from Copilot November 21, 2025 14:42
Copy link

Copilot AI left a 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.

@danielcivit danielcivit requested a review from Copilot November 25, 2025 12:00
Copy link

Copilot AI left a 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.

@danielcivit danielcivit merged commit 1db842a into master Nov 25, 2025
6 checks passed
@danielcivit danielcivit deleted the PTHMINT-84 branch November 25, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants