Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented May 7, 2025

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 Any with more specific types such as Union, object, or structured types like dict and list. Additionally, some unused imports of Any were removed to clean up the code.

Type Annotation Improvements:

  • API Response Enhancements:

    • Updated get_body_data in src/multisafepay/api/base/response/api_response.py to return Optional[Union[dict, list]] instead of Optional[Any] for better specificity.
    • Modified data and related methods in CustomApiResponse to use Optional[Union[dict, list]] instead of Optional[Any]. [1] [2]
  • Exception Handling:

    • Updated get_context_value in src/multisafepay/exception/api.py to return Optional[Union[str, int, float, bool, Dict, List]] instead of Any. [1] [2]
  • Utility Functions:

    • Replaced Any with object in utility functions such as process_value and dict_empty in src/multisafepay/util/dict_utils.py. [1] [2]
    • Updated __get_tax_rate_by_item in src/multisafepay/util/total_amount.py to return object instead of Any. [1] [2]

Code Cleanup:

  • Removed unused Any imports from several files, including src/multisafepay/util/dict_utils.py, src/multisafepay/util/total_amount.py, and test files. [1] [2] [3] [4] [5]

Configuration Update:

  • Removed ANN401 from the ignore list in pyproject.toml, likely to enforce stricter adherence to type annotation rules.

@zulquer zulquer requested a review from Copilot May 7, 2025 08:52
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 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.

@zulquer zulquer merged commit 9dccc4f into master May 7, 2025
6 checks passed
@zulquer zulquer deleted the PTHMINT-47 branch May 7, 2025 08:54
@codecov
Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.76%. Comparing base (782365b) to head (50ede7f).
Report is 1 commits behind head on master.

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

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