improve and add http Result utilities and protocols#62
Open
lykmapipo wants to merge 5 commits into
Open
Conversation
This: - Add `__iter__()` and `__len__()` methods to support iteration and length checking - Add a `map()` method to transform `ResultItem` - Add `extend()` method to append items into the underlying result list
This: - Remove the `.extend()` instance method from the `Result` class - Implement the `__add__` dunder method to allow merging `Result` with `Iterable` or `Result`
…nted in __add__ This: - Refine `__add__` type fallback logic to follow idiomatic Python `+` protocol - Update type annotation of `other` in `__add__` from `Iterable[_ResultItemT]` to `object` - Optimize `__len__` by directly checking underlying `_data`
This: - Add `flat_map()` utility to the `Result` class to allow transforming and flattening nested iterables - Clean up `Returns` docstrings from `Result` generator utilities
This: - Upgrade `actions/checkout` from v4.2.2 to v7.0.0 - Upgrade `actions/setup-python` from v5.4.0 to v6.3.0 - Upgrade `codecov/codecov-action` from v5.3.1 to v7.0.0
yaaNuamahGFW
left a comment
Collaborator
There was a problem hiding this comment.
One small safety issue in the new Result addition helper.
| TypeError: | ||
| If `other` is not iterable. | ||
| """ | ||
| if isinstance(other, Iterable): |
Collaborator
There was a problem hiding this comment.
__add__ currently accepts any iterable, so values like strings or dicts can be added and create invalid Result contents. Can we restrict this to another Result or a sequence of ResultItem instances?
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:
__iter__()method toResultto support iteration__len__()method toResultto support direct length checking__add__method toResultto support collection mergingmap()andflat_map()methods to transformResultitems