@@ -235,14 +235,14 @@ def _matches_context_value(
235235
236236
237237def _evaluate_not_contains (
238- segment_value : str | None ,
238+ segment_value : typing . Optional [ str ] ,
239239 context_value : ContextValue ,
240240) -> bool :
241241 return isinstance (context_value , str ) and str (segment_value ) not in context_value
242242
243243
244244def _evaluate_regex (
245- segment_value : str | None ,
245+ segment_value : typing . Optional [ str ] ,
246246 context_value : ContextValue ,
247247) -> bool :
248248 return (
@@ -252,7 +252,7 @@ def _evaluate_regex(
252252
253253
254254def _evaluate_modulo (
255- segment_value : str | None ,
255+ segment_value : typing . Optional [ str ] ,
256256 context_value : ContextValue ,
257257) -> bool :
258258 if not isinstance (context_value , (int , float )):
@@ -271,7 +271,9 @@ def _evaluate_modulo(
271271 return context_value % divisor == remainder
272272
273273
274- def _evaluate_in (segment_value : str | None , context_value : ContextValue ) -> bool :
274+ def _evaluate_in (
275+ segment_value : typing .Optional [str ], context_value : ContextValue
276+ ) -> bool :
275277 if segment_value :
276278 try :
277279 in_values = json .loads (segment_value )
@@ -294,11 +296,11 @@ def _evaluate_in(segment_value: str | None, context_value: ContextValue) -> bool
294296
295297def _context_value_typed (
296298 func : typing .Callable [..., bool ],
297- ) -> typing .Callable [[str | None , ContextValue ], bool ]:
299+ ) -> typing .Callable [[typing . Optional [ str ] , ContextValue ], bool ]:
298300 @wraps (func )
299301 def inner (
300- segment_value : str | None ,
301- context_value : ContextValue | semver .Version ,
302+ segment_value : typing . Optional [ str ] ,
303+ context_value : typing . Union [ ContextValue , semver .Version ] ,
302304 ) -> bool :
303305 with suppress (TypeError , ValueError ):
304306 if isinstance (context_value , str ) and is_semver (segment_value ):
@@ -313,7 +315,7 @@ def inner(
313315
314316
315317MATCHERS_BY_OPERATOR : dict [
316- ConditionOperator , typing .Callable [[str | None , ContextValue ], bool ]
318+ ConditionOperator , typing .Callable [[typing . Optional [ str ] , ContextValue ], bool ]
317319] = {
318320 constants .NOT_CONTAINS : _evaluate_not_contains ,
319321 constants .REGEX : _evaluate_regex ,
0 commit comments