Skip to content

Commit be59fc9

Browse files
Remove/fix noqa usages
* Passes a boolean as a kwarg * Removes unnecessary mutable vars (defined in __init__) * Remove unused "exported" vars
1 parent a418c76 commit be59fc9

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

protovalidate/internal/constraints.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def __init__(self, *, field_value: typing.Any = None, rule_value: typing.Any = N
247247
class 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

289289
class 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
541541
class 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

protovalidate/internal/string_format.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,3 @@ def format_list(self, arg: celtypes.ListType) -> celpy.Result:
190190

191191
def _format_duration(self, arg: celtypes.DurationType) -> celpy.Result:
192192
return f"{arg.seconds + Decimal(arg.microseconds) / Decimal(1_000_000):f}s"
193-
194-
195-
_default_format = StringFormat("en_US")
196-
format = _default_format.format # noqa: A001
197-
format_value = _default_format.format_value

0 commit comments

Comments
 (0)