Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions protovalidate/internal/cel_field_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import threading

import celpy
import celpy.celtypes

_has_state = threading.local()

Expand All @@ -32,14 +33,14 @@ def in_has() -> bool:


class InterpretedRunner(celpy.InterpretedRunner):
def evaluate(self, context):
def evaluate(self, context) -> celpy.celtypes.Value:
class Evaluator(celpy.Evaluator):
def macro_has_eval(self, exprlist):
def macro_has_eval(self, exprlist) -> celpy.celtypes.BoolType:
_has_state.in_has = True
result = super().macro_has_eval(exprlist)
_has_state.in_has = False
return result

e = Evaluator(ast=self.ast, activation=self.new_activation(context), functions=self.functions)
value = e.evaluate()
e = Evaluator(ast=self.ast, activation=self.new_activation())
value = e.evaluate(context)
return value
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ classifiers = [
dynamic = ["version"]
dependencies = [
"protobuf==6.*",
"cel-python==0.2.*",
"cel-python==0.4.*",
"google-re2>=1.1.20250722 ; python_full_version >= '3.13'",
]

[project.urls]
Expand Down
Loading
Loading