Skip to content

criteria: add split_criteria, raising CriteriaSyntaxError on unbalanced brackets - #6

Merged
m-messer merged 3 commits into
mainfrom
feat/split-criteria
Oct 16, 2026
Merged

m-messer merged 3 commits into
mainfrom
feat/split-criteria

Conversation

@m-messer

@m-messer m-messer commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Stacked on #5: merge that first, and this PR's base will then switch to main.

Moves split_criteria out of compareExpressions' evaluation.py into lambdafeedback.criteria.

Changes

  • split_criteria(criteria) in the new split.py splits on the commas outside (), [] and {}, and strips each criterion. Each kind of bracket is counted on its own.
  • New CriteriaSyntaxError (a CriteriaError and ValueError) for a malformed criteria string.
  • Behaviour change (CHANGELOG): a bracket closed before it is opened, or left open, now raises CriteriaSyntaxError. The old version silently stopped splitting at the first such bracket.

Downstream
compareExpressions can import this in place of its own copy. Criteria with unbalanced brackets will now raise instead of being split partially.

Verification

  • ruff, format and mypy are clean, and all four test suites pass.
  • New tests cover nested and mixed brackets, whitespace, a trailing comma, the empty string, and each unbalanced case.

🤖 Generated with Claude Code

…se `CriteriaSyntaxError` for invalid syntax, and update tests, module init, and changelog.
…ria, raise `CriteriaSyntaxError` for unsupported relations, and update tests, module init, and changelog.
criteria: add `where_substitutions` to read the substitutions of a `where` criterion
Base automatically changed from feat/quantity-criteria-grammar to main October 16, 2026 10:19
@m-messer
m-messer merged commit ed7aeff into main Oct 16, 2026
8 checks passed
@m-messer
m-messer deleted the feat/split-criteria branch October 16, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant