-
Notifications
You must be signed in to change notification settings - Fork 0
PTHMINT-46: Fix ruff ANN204 #17
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 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 |
src/multisafepay/util/message.py
Outdated
| __root__: List[Message] = Field(default_factory=list) | ||
|
|
||
| def __iter__(self: "MessageList"): | ||
| def __iter__(self: "MessageList") -> "MessageList": |
Copilot
AI
May 7, 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 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]).
| def __iter__(self: "MessageList") -> "MessageList": | |
| def __iter__(self: "MessageList") -> Iterator[Message]: |
| super().__init__(data=elements) | ||
|
|
||
| def __iter__(self: "Listing"): | ||
| def __iter__(self: "Listing") -> "Listing": |
Copilot
AI
May 7, 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 iter method returns an iterator over self.data but is annotated to return 'Listing'. It should return an iterator (for example, Iterator[T]) instead.
| def __iter__(self: "Listing") -> "Listing": | |
| def __iter__(self: "Listing") -> Iterator[T]: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
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.tomlconfiguration.Type Annotations for Return Values:
-> Nonereturn type annotations to__init__methods in multiple classes, such asAbstractManager,AuthManager,CaptureManager, and others, ensuring consistency and clarity in constructor definitions. [1] [2] [3] and more)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:
ANN204from theignorelist in thepyproject.tomlfile, likely to enforce stricter adherence to type annotation rules.