PTHMINT-47: Fix ruff ANN401#18
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request refines type annotations and cleans up unused imports across the codebase to improve type safety and consistency. Key changes include:
- Replacing generic Any annotations with more specific types (e.g. Union[dict, list], object) in API responses, exceptions, and utility functions.
- Removing unused Any imports from several files.
- Updating the pyproject.toml configuration to enforce stricter type annotation rules.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py | Updated MockItem to use object instead of Any. |
| tests/multisafepay/unit/api/base/listings/test_unit_listing.py | Updated MockItem to use object instead of Any. |
| tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py | Updated MockItem to use object instead of Any. |
| src/multisafepay/util/total_amount.py | Changed return type of __get_tax_rate_by_item from Any to object and removed unused Any import. |
| src/multisafepay/util/dict_utils.py | Replaced Any with object for parameters in process_value and dict_empty; removed unused Any import. |
| src/multisafepay/exception/api.py | Changed get_context_value type annotation from Any to a more specific union of types. |
| src/multisafepay/api/base/response/custom_api_response.py | Updated data attribute and method return types to Optional[Union[dict, list]]. |
| src/multisafepay/api/base/response/api_response.py | Updated return type of get_body_data from Any to Optional[Union[dict, list]]. |
| pyproject.toml | Removed ANN401 from the ignore list to enforce stricter type annotation requirements. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #18 +/- ##
==========================================
- Coverage 90.76% 90.76% -0.01%
==========================================
Files 106 106
Lines 2307 2306 -1
==========================================
- Hits 2094 2093 -1
Misses 213 213 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refines type annotations across multiple files to improve type safety and consistency in the codebase. The changes primarily involve replacing the use of
Anywith more specific types such asUnion,object, or structured types likedictandlist. Additionally, some unused imports ofAnywere removed to clean up the code.Type Annotation Improvements:
API Response Enhancements:
get_body_datainsrc/multisafepay/api/base/response/api_response.pyto returnOptional[Union[dict, list]]instead ofOptional[Any]for better specificity.dataand related methods inCustomApiResponseto useOptional[Union[dict, list]]instead ofOptional[Any]. [1] [2]Exception Handling:
get_context_valueinsrc/multisafepay/exception/api.pyto returnOptional[Union[str, int, float, bool, Dict, List]]instead ofAny. [1] [2]Utility Functions:
Anywithobjectin utility functions such asprocess_valueanddict_emptyinsrc/multisafepay/util/dict_utils.py. [1] [2]__get_tax_rate_by_iteminsrc/multisafepay/util/total_amount.pyto returnobjectinstead ofAny. [1] [2]Code Cleanup:
Anyimports from several files, includingsrc/multisafepay/util/dict_utils.py,src/multisafepay/util/total_amount.py, and test files. [1] [2] [3] [4] [5]Configuration Update:
ANN401from theignorelist inpyproject.toml, likely to enforce stricter adherence to type annotation rules.