Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented May 7, 2025

This pull request introduces type annotations for return values in various methods across the codebase to improve type safety and readability. Additionally, a minor adjustment was made to the pyproject.toml configuration.

Type Annotations for Return Values:

  • Added -> None return type annotations to __init__ methods in multiple classes, such as AbstractManager, AuthManager, CaptureManager, and others, ensuring consistency and clarity in constructor definitions. [1] [2] [3] and more)
  • Updated return type annotations for iterator and collection-related methods in Listing, MessageList, and similar classes, such as __iter__, __getitem__, and __len__, to specify the expected return types (e.g., -> int, -> "Listing", -> "Message"). [1] [2] [3] [4]

Configuration Adjustments:

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

@zulquer zulquer requested a review from Copilot May 7, 2025 07:36
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 addresses type annotation improvements across the codebase, specifically adding explicit return type annotations (mostly -> None) for constructors and other methods to enhance type safety and readability. It also updates the pyproject.toml configuration by removing ANN204 from the ignore list.

  • Added explicit return type annotations in constructors and iterator methods.
  • Updated return type hints for collection methods such as iter, getitem, and len.
  • Improved configuration to enforce stricter type annotation rules.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/multisafepay/value_object/date.py Updated init return annotation to -> None
src/multisafepay/util/message.py Updated iter, getitem, and len return types
src/multisafepay/sdk.py Updated init return annotation to -> None
src/multisafepay/exception/api.py Updated init return annotation to -> None
src/multisafepay/client/client.py Updated init return annotation to -> None
src/multisafepay/api/paths/* (TransactionManager, RecurringManager, etc.) Updated all init return annotations to -> None
src/multisafepay/api/base/* (CustomApiResponse, ListingPager, Listing) Updated init, iter, and len return annotations
pyproject.toml Removed ANN204 from ignore list

__root__: List[Message] = Field(default_factory=list)

def __iter__(self: "MessageList"):
def __iter__(self: "MessageList") -> "MessageList":
Copy link

Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

The method iter returns an iterator over messages (using iter(self.root)) but its return type is annotated as 'MessageList'. It should be annotated with an iterator type (e.g., Iterator[Message]).

Suggested change
def __iter__(self: "MessageList") -> "MessageList":
def __iter__(self: "MessageList") -> Iterator[Message]:

Copilot uses AI. Check for mistakes.
super().__init__(data=elements)

def __iter__(self: "Listing"):
def __iter__(self: "Listing") -> "Listing":
Copy link

Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

The iter method returns an iterator over self.data but is annotated to return 'Listing'. It should return an iterator (for example, Iterator[T]) instead.

Suggested change
def __iter__(self: "Listing") -> "Listing":
def __iter__(self: "Listing") -> Iterator[T]:

Copilot uses AI. Check for mistakes.
@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 (02e1d69) to head (1a41542).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #17   +/-   ##
=======================================
  Coverage   90.76%   90.76%           
=======================================
  Files         106      106           
  Lines        2307     2307           
=======================================
  Hits         2094     2094           
  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 782365b into master May 7, 2025
7 checks passed
@zulquer zulquer deleted the PTHMINT-46 branch May 7, 2025 08:32
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