3131import sys
3232import threading
3333from dataclasses import dataclass
34- from typing import Any , Callable , Mapping , MutableSequence , Optional , Sequence , Type , MutableMapping
34+ from typing import Any , Callable , Mapping , MutableSequence , Optional , Sequence , Type , MutableMapping , Union
3535
3636from jsonata import functions , jexception , parser , signature as sig , timebox , utils
3737
@@ -1976,7 +1976,7 @@ def is_output_convert_nulls(self) -> bool:
19761976 def set_output_convert_nulls (self , output_convert_nulls : bool ) -> None :
19771977 self .output_convert_nulls = output_convert_nulls
19781978
1979- def evaluate (self , input : Optional [Any ], bindings : Optional [Frame ] = None ) -> Optional [Any ]:
1979+ def evaluate (self , input : Optional [Any ], bindings : Optional [Union [ Frame , Mapping [ str , Any ]] ] = None ) -> Optional [Any ]:
19801980 # throw if the expression compiled with syntax errors
19811981 if self .errors is not None :
19821982 raise jexception .JException ("S0500" , 0 )
@@ -1986,7 +1986,9 @@ def evaluate(self, input: Optional[Any], bindings: Optional[Frame] = None) -> Op
19861986 # var exec_env
19871987 # the variable bindings have been passed in - create a frame to hold these
19881988 exec_env = self .create_frame (self .environment )
1989- for k , v in bindings .bindings .items ():
1989+ # accept either a Frame or a plain mapping (e.g. dict) of variable bindings
1990+ items = bindings .bindings if isinstance (bindings , Jsonata .Frame ) else bindings
1991+ for k , v in items .items ():
19901992 exec_env .bind (k , v )
19911993 else :
19921994 exec_env = self .environment
0 commit comments