{"id":23447,"library":"common-expression-language","title":"Common Expression Language","description":"Python bindings for the Common Expression Language (CEL), providing evaluation, compilation, and CLI tools. Current version 0.5.6, requires Python >=3.11. Development is active with regular releases.","status":"active","version":"0.5.6","language":"python","source_language":"en","source_url":"https://github.com/hardbyte/python-common-expression-language","tags":["cel","expression-language","evaluation","bindings"],"install":[{"cmd":"pip install common-expression-language","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Rust core library for CEL evaluation","package":"cel-rust (cel crate)","optional":false}],"imports":[{"note":"Package name is 'cel', not 'common_expression_language'","wrong":"from common_expression_language import evaluate","symbol":"evaluate","correct":"from cel import evaluate"}],"quickstart":{"code":"from cel import evaluate\n\n# Evaluate a simple expression\nresult = evaluate(\"1 + 2\")\nprint(result)  # 3\n\n# With a context\ncontext = {\"age\": 18}\nresult = evaluate(\"age > 21\", context)\nprint(result)  # False\n\n# Use custom Python functions\ndef is_adult(age):\n    return age > 21\n\ncontext = {\"is_adult\": is_adult, \"age\": 18}\nresult = evaluate(\"is_adult(age)\", context)\nprint(result)  # False","lang":"python","description":"Basic usage: evaluate CEL expressions with optional context and custom functions."},"warnings":[{"fix":"Upgrade to >=0.5.6 for dict subclass support.","message":"Python types may be automatically converted to CEL types. Be cautious with dictionaries: dict subclasses are now properly handled (v0.5.6), but avoid relying on insertion order preservation in older versions.","severity":"gotcha","affected_versions":"<0.5.6"},{"fix":"No action needed for Python users; Rust bindings must update imports from cel_interpreter:: to cel:: and use IntoFunction trait.","message":"Rust API breaking change in v0.5.0: cel-interpreter crate renamed to cel, function registration changed. Python API unaffected.","severity":"breaking","affected_versions":"0.5.0"},{"fix":"Use .value property or isinstance() checks for OptionalValue.","message":"Optional values are surfaced as cel.OptionalValue objects (since v0.5.5) instead of debug strings. Code relying on string output may break.","severity":"gotcha","affected_versions":">=0.5.5"},{"fix":"Call via python -m cel or check with `which cel`.","message":"The cel CLI command may conflict with other packages. On some systems, it might be shadowed by another executable named 'cel'.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install with `pip install common-expression-language` and then `from cel import evaluate`.","cause":"Package is installed as 'common-expression-language' but imported as 'cel'.","error":"ModuleNotFoundError: No module named 'cel'"},{"fix":"Convert unsupported types to supported ones (int, float, str, bool, list, dict, None) before passing to evaluate().","cause":"CEL cannot convert some Python types (e.g., custom objects) to CEL values.","error":"ValueError: Unsupported type: <class '...'>"},{"fix":"Check expression syntax: ensure operators and function calls are valid CEL. Use cel.parse() to validate syntax separately.","cause":"CEL expression syntax error or type mismatch during evaluation.","error":"cel.exceptions.EvaluationError: ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}