Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented May 6, 2025

This pull request introduces type annotations to several methods across the codebase, enhancing type safety and improving code readability. It also includes minor adjustments to imports and configuration files. Below is a categorized summary of the most important changes:

Type Annotations for Methods

  • Added return type annotations to various methods, such as append in listing.py, get_data in custom_api_response.py, and add_status in capture_request.py. These changes ensure that method return types are explicit and consistent. [1] [2] [3]

  • Updated methods in checkout_data.py to include return type annotations, such as add_items, get_items, and get_item_by_merchant_item_id, improving clarity in the refund request components. [1] [2] [3]

  • Added type annotations to validators in value object models like ApiKey, Country, and Currency, ensuring that validation methods explicitly return str. [1] [2] [3]

Configuration and Import Adjustments

  • Removed the ANN201 rule from the ignore list in pyproject.toml, likely indicating stricter adherence to type annotation rules.

  • Added the Any type to imports in api.py to support new type annotations.

These changes collectively improve the maintainability and robustness of the codebase by making type expectations explicit.

@zulquer zulquer requested a review from Copilot May 6, 2025 15:23
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 type safety and code readability by adding explicit return type annotations to methods and validators, and updates configuration to enforce stricter type annotation rules. Key changes include:

  • Adding return type annotations to various validators and model methods.
  • Updating type annotations for checkout and cart-related methods.
  • Removing the "ANN201" rule from the pyproject.toml ignore list.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/multisafepay/value_object/ip_address.py Added explicit return type to IP address validator.
src/multisafepay/value_object/iban_number.py Added explicit return type to IBAN number validator.
src/multisafepay/value_object/gender.py Added return type to validator; note possible naming inconsistency.
src/multisafepay/value_object/email_address.py Added explicit return type to email address validator.
src/multisafepay/value_object/currency.py Added explicit return type to currency validator.
src/multisafepay/value_object/country.py Added explicit return type to country validator.
src/multisafepay/util/version.py Added return type to set_plugin_version method.
src/multisafepay/util/dict_utils.py Added return type annotation to merge_recursive.
src/multisafepay/exception/api.py Added explicit return type to get_context_value.
src/multisafepay/client/api_key.py Added explicit return type to API key validator.
src/multisafepay/api/shared/cart/shopping_cart.py Added return type annotations to add_items and add_item methods.
src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py Added return type annotations to checkout data methods (add_items, add_item, get_items, etc.).
src/multisafepay/api/paths/capture/request/capture_request.py Added return types to add_status and add_reason methods.
src/multisafepay/api/base/response/custom_api_response.py Added explicit return type to get_data method.
src/multisafepay/api/base/listings/listing.py Added explicit return type annotation to the append method.
pyproject.toml Removed the "ANN201" rule from the ignore list to enforce stricter type annotations.
Comments suppressed due to low confidence (2)

src/multisafepay/value_object/gender.py:29

  • [nitpick] The function name 'validate_ip_address' is misleading in the context of validating a gender value. Consider renaming it to 'validate_gender' for clarity.
def validate_ip_address(cls: "Gender", value: str) -> str:

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

  • The default parameter value for 'items' is an empty tuple, which conflicts with the expected List[CartItem] type. Consider using an empty list ([]) instead.
def add_items(self: "CheckoutData", items: List[CartItem] = (),

@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.76%. Comparing base (48a9960) to head (c9a7b48).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #16   +/-   ##
=======================================
  Coverage   90.76%   90.76%           
=======================================
  Files         106      106           
  Lines        2306     2307    +1     
=======================================
+ Hits         2093     2094    +1     
  Misses        213      213           

☔ 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.

@zulquer zulquer merged commit 02e1d69 into master May 6, 2025
7 checks passed
@zulquer zulquer deleted the PTHMINT-45 branch May 6, 2025 15:40
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.

2 participants