Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented May 6, 2025

This pull request introduces type hinting improvements across multiple files in the codebase, enhancing code clarity and consistency. The changes include adding explicit self type annotations in method signatures, replacing generic types like dict with more specific Dict, and updating type hints for optional attributes. These updates improve readability and align the code with modern Python typing practices.

Type Hinting Improvements:

General Updates:

  • Added explicit self type annotations (e.g., self: "ClassName") in method signatures across various classes to improve type clarity. Examples include AbstractManager, Decorator, Listing, ListingPager, ApiResponse, and others. [1] [2] [3] [4] [5] [6]

Specific Type Replacements:

  • Replaced dict with Dict and added type annotations for optional attributes and parameters (e.g., Optional[Dict], Optional[Pager]) in classes like Decorator, ListingPager, and ApiResponse. [1] [2] [3]

Method-Specific Updates:

Additional Imports:

  • Added necessary imports for type hinting, such as Optional and Dict, in files where they were missing.

These changes improve the maintainability and robustness of the code by making type expectations explicit and reducing potential type-related errors.

@zulquer zulquer requested a review from Copilot May 6, 2025 14:43
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 fixes ruff ANN101 errors by adding explicit self type annotations and refining type hints throughout the codebase.

  • Added explicit self type annotations in method signatures across many modules.
  • Replaced generic dict types with specific Dict and updated related type hints.
  • Updated pyproject.toml to remove the ANN101 ignore so that type annotations are explicitly enforced.

Reviewed Changes

Copilot reviewed 76 out of 76 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/multisafepay/api/paths/orders/request/components/checkout_options.py Added explicit self type annotations in CheckoutOptions.
src/multisafepay/api/paths/orders/order_manager.py Updated method signatures with explicit self type annotations.
src/multisafepay/api/paths/orders/order_id/update/request/update_request.py Added self type annotations to update request methods.
src/multisafepay/api/paths/orders/order_id/refund/request/refund_request.py Added explicit self type annotations in refund request methods.
src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py Added self type annotations in CheckoutData methods.
src/multisafepay/api/paths/orders/order_id/capture/request/capture_request.py Added self type annotations in capture request methods.
src/multisafepay/api/paths/me/me_manager.py Updated self type annotation for MeManager.
src/multisafepay/api/paths/issuers/issuer_manager.py Added explicit self type annotations for method signatures.
src/multisafepay/api/paths/gateways/gateway_manager.py Updated self type annotation in GatewayManager methods.
src/multisafepay/api/paths/categories/category_manager.py Added self type annotations in CategoryManager.
src/multisafepay/api/paths/capture/request/capture_request.py Added self type annotations in CaptureRequest methods.
src/multisafepay/api/paths/capture/capture_manager.py Updated self type annotations in CaptureManager.
src/multisafepay/api/paths/auth/auth_manager.py Updated self type annotations in AuthManager methods.
src/multisafepay/api/base/response/custom_api_response.py Updated self type annotation in CustomApiResponse.get_data.
src/multisafepay/api/base/response/api_response.py Added explicit self type annotations in ApiResponse accessors.
src/multisafepay/api/base/listings/listing_pager.py Refined type annotations and updated init and get_pager signatures.
src/multisafepay/api/base/listings/listing.py Updated self type annotations across Listing class methods.
src/multisafepay/api/base/decorator.py Updated type annotations from dict to Dict and added self type annotations.
src/multisafepay/api/base/abstract_manager.py Updated self type annotation in AbstractManager.init.
pyproject.toml Removed the ignore for ANN101 to enforce explicit self type annotations.
Comments suppressed due to low confidence (1)

src/multisafepay/api/base/decorator.py:21

  • Ensure that 'Dict' is imported from the typing module in this file to prevent a NameError when using this type annotation.
dependencies: Optional[Dict]

items: Optional[List[CartItem]]

def add_items(self, items: List[CartItem] = ()):
def add_items(self: "CheckoutData", items: List[CartItem] = ()):
Copy link

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value for the 'items' parameter is set to an empty tuple, but the type hint specifies a List. Consider using a list literal ([]) as the default to match the expected type.

Suggested change
def add_items(self: "CheckoutData", items: List[CartItem] = ()):
def add_items(self: "CheckoutData", items: List[CartItem] = []):

Copilot uses AI. Check for mistakes.
@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 (93bacee) to head (5d94daf).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #14   +/-   ##
=======================================
  Coverage   90.75%   90.76%           
=======================================
  Files         106      106           
  Lines        2305     2306    +1     
=======================================
+ Hits         2092     2093    +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 48a9960 into master May 6, 2025
7 checks passed
@zulquer zulquer deleted the PTHMINT-42 branch May 6, 2025 14:47
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