Skip to content

Add python min/max syntatic sugar#221

Merged
gordonwatts merged 1 commit intomasterfrom
codex/implement-builtin-call-handling-for-min-and-max
Feb 14, 2026
Merged

Add python min/max syntatic sugar#221
gordonwatts merged 1 commit intomasterfrom
codex/implement-builtin-call-handling-for-min-and-max

Conversation

@gordonwatts
Copy link
Member

Motivation

  • Make behavior explicit in docs that builtin min/max called with a single list/generator comprehension lowers to Min(...)/Max(...) so aggregate simplification can process them.
  • Add tests to cover both successful lowering and invalid signature cases for min/max when used with comprehensions.

Description

  • Added _resolve_min_max_call to func_adl/ast/syntatic_sugar.py to detect min/max calls on comprehensions, validate signatures, and return Min(...)/Max(...) AST calls.
  • Wired the new resolver into the call handling in resolve_syntatic_sugar so it runs after the existing any/all lowering.
  • Updated documentation in README.md and docs/source/generic/query_structure.md to describe the min/max lowering and show an example aggregate-form rewrite using Max(...).
  • Extended tests/ast/test_syntatic_sugar.py with positive tests for min/max lowering and additional negative tests asserting invalid signatures raise ValueError.

Testing

  • Ran pytest -q tests/ast/test_syntatic_sugar.py and it succeeded (46 passed).
  • Ran the full suite with pytest -q and it succeeded (438 passed).
  • Ran black --check func_adl tests and it succeeded, while black --check that included README.md and the modified markdown docs failed due to Black parsing those markdown files as Python (markdown files are not targeted by black), so code and tests remain formatted.
  • Ran flake8 func_adl tests and it succeeded with no issues.

Codex Task

@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.76%. Comparing base (a6a9cc1) to head (b351352).

Files with missing lines Patch % Lines
func_adl/ast/syntatic_sugar.py 77.27% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
- Coverage   96.01%   95.76%   -0.26%     
==========================================
  Files          15       15              
  Lines        1607     1629      +22     
==========================================
+ Hits         1543     1560      +17     
- Misses         64       69       +5     
Flag Coverage Δ
unittests 95.76% <77.27%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@gordonwatts gordonwatts changed the title Document min/max syntatic sugar and add comprehension tests Add python min/max syntatic sugar Feb 14, 2026
@gordonwatts gordonwatts self-assigned this Feb 14, 2026
@gordonwatts gordonwatts added the enhancement New feature or request label Feb 14, 2026
@gordonwatts gordonwatts force-pushed the codex/implement-builtin-call-handling-for-min-and-max branch from 2cba952 to b351352 Compare February 14, 2026 18:41
@gordonwatts gordonwatts merged commit 5f581dc into master Feb 14, 2026
19 checks passed
@gordonwatts gordonwatts deleted the codex/implement-builtin-call-handling-for-min-and-max branch February 14, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants