Skip to content

Conversation

@hardbyte
Copy link
Owner

@hardbyte hardbyte commented Aug 9, 2025

Introduces a new EvaluationMode enum that allows developers to control how CEL expressions handle type compatibility, providing flexibility between Python-friendly type coercion and strict CEL specification compliance.

🎯 Evaluation Modes

  • EvaluationMode.PYTHON (default for Python API): Enables Python-friendly type promotions (e.g., int + float → float)
  • EvaluationMode.STRICT (default for CLI): Enforces strict CEL type rules with no automatic coercion

API Changes

Python API:

 
from cel import evaluate, EvaluationMode

# Python-friendly (default)
result = evaluate("1 + 2.5")  # → 3.5

# Explicit modes
result = evaluate("1 + 2.5", mode=EvaluationMode.PYTHON)  # → 3.5
result = evaluate("1 + 2.5", mode="strict")  # → TypeError

CLI:

$ cel '1 + 2.5' --mode python  # → 3.5
$ cel '1 + 2.5' --mode strict  # → Error (default)

@hardbyte hardbyte merged commit 317edcd into main Aug 11, 2025
15 checks passed
@hardbyte hardbyte deleted the feat/strict-mode branch August 11, 2025 10:11
@hardbyte hardbyte mentioned this pull request Aug 11, 2025
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.

2 participants