11import builtins
2- from typing import Any , Callable , Dict , Mapping , Optional
2+ from typing import Any , Callable , Dict , Mapping , Optional , Tuple
33
44from djc_core .djc_core import safe_eval as safe_eval_rust
55from djc_core .djc_safe_eval .error import error_context , _format_error_with_context
@@ -73,7 +73,7 @@ def safe_eval(
7373 def variable_fn (
7474 __context : Mapping [str , Any ],
7575 __source : str ,
76- __token : tuple [int , int ],
76+ __token : Tuple [int , int ],
7777 var_name : str ,
7878 ) -> Any :
7979 if not validate_variable (var_name ):
@@ -88,7 +88,7 @@ def variable_fn(
8888 def attribute_fn (
8989 __context : Mapping [str , Any ],
9090 __source : str ,
91- __token : tuple [int , int ],
91+ __token : Tuple [int , int ],
9292 obj : Any ,
9393 attr_name : str ,
9494 ) -> Any :
@@ -106,7 +106,7 @@ def attribute_fn(
106106 def subscript_fn (
107107 __context : Mapping [str , Any ],
108108 __source : str ,
109- __token : tuple [int , int ],
109+ __token : Tuple [int , int ],
110110 obj : Any ,
111111 key : Any ,
112112 ) -> Any :
@@ -122,7 +122,7 @@ def subscript_fn(
122122 def call_fn (
123123 __context : Mapping [str , Any ],
124124 __source : str ,
125- __token : tuple [int , int ],
125+ __token : Tuple [int , int ],
126126 func : Callable ,
127127 * args : Any ,
128128 ** kwargs : Any ,
@@ -139,7 +139,7 @@ def call_fn(
139139 def assign_fn (
140140 __context : Mapping [str , Any ],
141141 __source : str ,
142- __token : tuple [int , int ],
142+ __token : Tuple [int , int ],
143143 var_name : str ,
144144 value : Any ,
145145 ) -> Any :
@@ -242,7 +242,7 @@ def evaluate(context: Dict[str, Any]) -> Any:
242242# Each interceptor function receives the same 3 first positional arguments:
243243# - __context: Mapping[str, Any] - The evaluation context
244244# - __source: str - The source code
245- # - __token: tuple [int, int] - The token tuple (start_index, end_index)
245+ # - __token: Tuple [int, int] - The token tuple (start_index, end_index)
246246#
247247# The __source and __token arguments are used by `@error_context` decorator to add the position
248248# where the error occurred to the error message.
@@ -256,7 +256,7 @@ def evaluate(context: Dict[str, Any]) -> Any:
256256
257257@error_context ("variable" )
258258def variable (
259- __context : Mapping [str , Any ], __source : str , __token : tuple [int , int ], var_name : str
259+ __context : Mapping [str , Any ], __source : str , __token : Tuple [int , int ], var_name : str
260260) -> Any :
261261 """Look up a variable in the evaluation context, e.g. `my_var`"""
262262 if not is_safe_variable (var_name ):
@@ -268,7 +268,7 @@ def variable(
268268def attribute (
269269 __context : Mapping [str , Any ],
270270 __source : str ,
271- __token : tuple [int , int ],
271+ __token : Tuple [int , int ],
272272 obj : Any ,
273273 attr_name : str ,
274274) -> Any :
@@ -284,7 +284,7 @@ def attribute(
284284def subscript (
285285 __context : Mapping [str , Any ],
286286 __source : str ,
287- __token : tuple [int , int ],
287+ __token : Tuple [int , int ],
288288 obj : Any ,
289289 key : Any ,
290290) -> Any :
@@ -300,7 +300,7 @@ def subscript(
300300def call (
301301 __context : Mapping [str , Any ],
302302 __source : str ,
303- __token : tuple [int , int ],
303+ __token : Tuple [int , int ],
304304 func : Callable ,
305305 * args : Any ,
306306 ** kwargs : Any ,
@@ -319,7 +319,7 @@ def call(
319319def assign (
320320 __context : Mapping [str , Any ],
321321 __source : str ,
322- __token : tuple [int , int ],
322+ __token : Tuple [int , int ],
323323 var_name : str ,
324324 value : Any ,
325325) -> Any :
@@ -338,7 +338,7 @@ def assign(
338338def slice (
339339 __context : Mapping [str , Any ],
340340 __source : str ,
341- __token : tuple [int , int ],
341+ __token : Tuple [int , int ],
342342 lower : Any = None ,
343343 upper : Any = None ,
344344 step : Any = None ,
@@ -355,10 +355,10 @@ def slice(
355355def interpolation (
356356 __context : Mapping [str , Any ],
357357 __source : str ,
358- __token : tuple [int , int ],
358+ __token : Tuple [int , int ],
359359 value : Any ,
360360 expression : str ,
361- conversion : str | None ,
361+ conversion : Optional [ str ] ,
362362 format_spec : str ,
363363) -> Any :
364364 """Process t-string interpolation."""
@@ -371,7 +371,7 @@ def interpolation(
371371
372372@error_context ("template" )
373373def template (
374- __context : Mapping [str , Any ], __source : str , __token : tuple [int , int ], * parts : Any
374+ __context : Mapping [str , Any ], __source : str , __token : Tuple [int , int ], * parts : Any
375375) -> Any :
376376 """Construct a template from parts."""
377377 try :
@@ -385,7 +385,7 @@ def template(
385385def format (
386386 __context : Mapping [str , Any ],
387387 __source : str ,
388- __token : tuple [int , int ],
388+ __token : Tuple [int , int ],
389389 template_string : str ,
390390 * args : Any ,
391391) -> str :
0 commit comments