Repository navigation
Return empty min and max defaults without applying key - #233
Open
Apeksha9389 wants to merge 1 commit into
Open
Apeksha9389 wants to merge 1 commit into
Apeksha9389 wants to merge 1 commit into
Conversation
1 task done
Author
|
Could a maintainer approve the pending CI runs and review this PR for merging? Local tests, Flake8, Black, MyPy, and PyRight all pass. Thank you. |
Owner
|
Hi @Apeksha9389, please be aware that this package is maintained by humans. Going through 4 issues and 4 PRs takes time. Your posts and changes have been seen, there is no need to prod after just 2 hours. |
Owner
|
Please see the comments on #237. |
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 PR fixes
min()andmax()applying their key function to the fallback value of an empty iterable. For example,await min([], key=lambda record: record["priority"], default=None)raisesTypeErrorinstead of returningNone. Defaults need not have the same shape as input records.Handle initial iterator exhaustion before evaluating a key. Return the provided default unchanged, and retain the existing
ValueErrorwhen there is no default. Nonempty input still evaluates keys even if its first item is identical to the default.Eight new regressions fail on master and pass here, covering min/max, sync/async inputs and sync/async keys. Two positive controls distinguish empty input from an actual item identical to the fallback. This is independent of the tie-selection fix in #231, which leaves the empty-input path unchanged.
Validation on Python 3.12: 412 tests pass. Repository-wide Flake8, Black, MyPy and PyRight pass. Other interpreter versions are left to CI.
Prepared with AI assistance; reproduced and tested locally.
Closes #237