-
Notifications
You must be signed in to change notification settings - Fork 0
PTHMINT-42: Fix ruff error ANN101 occurrences #14
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
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 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] = ()): |
Copilot
AI
May 6, 2025
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.
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.
| def add_items(self: "CheckoutData", items: List[CartItem] = ()): | |
| def add_items(self: "CheckoutData", items: List[CartItem] = []): |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
This pull request introduces type hinting improvements across multiple files in the codebase, enhancing code clarity and consistency. The changes include adding explicit
selftype annotations in method signatures, replacing generic types likedictwith more specificDict, 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:
selftype annotations (e.g.,self: "ClassName") in method signatures across various classes to improve type clarity. Examples includeAbstractManager,Decorator,Listing,ListingPager,ApiResponse, and others. [1] [2] [3] [4] [5] [6]Specific Type Replacements:
dictwithDictand added type annotations for optional attributes and parameters (e.g.,Optional[Dict],Optional[Pager]) in classes likeDecorator,ListingPager, andApiResponse. [1] [2] [3]Method-Specific Updates:
selftype annotations and refined return types, such asOptional[Pager]andList[T], in classes likeListingPagerandApiResponse. (src/multisafepay/api/base/listings/listing_pager.pyL22-R45, F2980c15L370R382)Additional Imports:
OptionalandDict, 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.