Repository navigation
Allow independent default values for empty min/max inputs - #233
Apeksha9389 wants to merge 2 commits into
Conversation
|
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. |
|
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. |
|
Please see the comments on #237. |
|
So, do you want to make the change as noted in the ticket? |
|
Updated the definitions in d95e4e3. The public min/max overloads infer the item type without a default and the union of item/default types when a default is supplied. The internal _min_max now uses a separate type variable for the default instead of tying it to LT. The key still accepts only iterable items. Added MyPy/PyRight assertions for keyed records with a None default, integer inputs with a string default, and calls without a default. Both type checkers pass, along with all 412 runtime tests, Black and Flake8 on the source, runtime tests and changed type-test file. The PR description now describes this as a behavior and typing change rather than a violation of the previous signature. |
|
See #230 (comment) |
Align empty-input
min()andmax()with Python's builtins by returning the supplied default without applying the key. This intentionally relaxes the previous internal signature, which tied the fallback to the key's input type.The public overloads now infer the iterable's item type without a default and a union of the item and independent default types when a default is supplied.
_min_maxuses a separate default type variable. Documentation states that defaults are returned unchanged and may have a different type. Nonempty input still evaluates its keys, even if an actual item is identical to the fallback.Runtime regressions cover sync/async input and sync/async keys. Type tests assert inference for keyed records with a None default, integer inputs with a string default, and calls without a default.
Validation on Python 3.12: all 412 runtime tests pass. Black, MyPy and PyRight pass. Flake8 passes on the source, runtime tests and changed type-test file. Running Flake8 over all type tests additionally reports pre-existing B019/B911 findings in unrelated files. Other interpreter versions are left to CI.
Prepared with AI assistance; reproduced and tested locally.
Closes #237