@@ -247,7 +247,7 @@ def __init__(self, *, field_value: typing.Any = None, rule_value: typing.Any = N
247247class ConstraintContext :
248248 """The state associated with a single constraint evaluation."""
249249
250- def __init__ (self , fail_fast : bool = False , violations : typing .Optional [list [Violation ]] = None ): # noqa: FBT001, FBT002
250+ def __init__ (self , * , fail_fast : bool = False , violations : typing .Optional [list [Violation ]] = None ):
251251 self ._fail_fast = fail_fast
252252 if violations is None :
253253 violations = []
@@ -283,13 +283,13 @@ def has_errors(self) -> bool:
283283 return len (self ._violations ) > 0
284284
285285 def sub_context (self ):
286- return ConstraintContext (self ._fail_fast )
286+ return ConstraintContext (fail_fast = self ._fail_fast )
287287
288288
289289class ConstraintRules :
290290 """The constraints associated with a single 'rules' message."""
291291
292- def validate (self , ctx : ConstraintContext , message : message .Message ): # noqa: ARG002
292+ def validate (self , ctx : ConstraintContext , _ : message .Message ):
293293 """Validate the message against the rules in this constraint."""
294294 ctx .add (Violation (constraint_id = "unimplemented" , message = "Unimplemented" ))
295295
@@ -541,9 +541,6 @@ def _validate_value(self, ctx: ConstraintContext, val: typing.Any, *, for_key: b
541541class AnyConstraintRules (FieldConstraintRules ):
542542 """Rules for an Any field."""
543543
544- _in : list [str ] = [] # noqa: RUF012
545- _not_in : list [str ] = [] # noqa: RUF012
546-
547544 _in_rule_path : typing .ClassVar [validate_pb2 .FieldPath ] = validate_pb2 .FieldPath (
548545 elements = [
549546 _field_to_element (validate_pb2 .AnyRules .DESCRIPTOR .fields_by_number [validate_pb2 .AnyRules .IN_FIELD_NUMBER ]),
@@ -576,8 +573,10 @@ def __init__(
576573 field_level : validate_pb2 .FieldConstraints ,
577574 ):
578575 super ().__init__ (env , funcs , field , field_level )
576+ self ._in = []
579577 if getattr (field_level .any , "in" ):
580578 self ._in = getattr (field_level .any , "in" )
579+ self ._not_in = []
581580 if field_level .any .not_in :
582581 self ._not_in = field_level .any .not_in
583582
0 commit comments