Skip to content

Commit 1b93f64

Browse files
committed
make format
1 parent 5fc07eb commit 1b93f64

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

protovalidate/internal/rules.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ def add_rule(
407407

408408
class MessageOneofRule(Rules):
409409
"""Validates a single buf.validate.MessageOneofRule given via the message option (buf.validate.message).oneof"""
410+
410411
def __init__(self, fields: typing.List[descriptor.FieldDescriptor], required: bool):
411412
self._fields = fields
412413
self._required = required
@@ -417,14 +418,14 @@ def validate(self, ctx: RuleContext, msg: message.Message):
417418
ctx.add(
418419
Violation(
419420
rule_id="message.oneof",
420-
message=f"only one of {", ".join([field.name for field in self._fields])} can be set",
421+
message=f"only one of {', '.join([field.name for field in self._fields])} can be set",
421422
)
422423
)
423424
if self._required and num_set_fields == 0:
424425
ctx.add(
425426
Violation(
426427
rule_id="message.oneof",
427-
message=f"one of {", ".join([field.name for field in self._fields])} must be set",
428+
message=f"one of {', '.join([field.name for field in self._fields])} must be set",
428429
)
429430
)
430431

@@ -457,7 +458,7 @@ def add_oneof(
457458
if name in self._desc.fields_by_name:
458459
fields.append(self._desc.fields_by_name[name])
459460
else:
460-
msg = f"field \"{name}\" not found in message {self._desc.full_name}"
461+
msg = f'field "{name}" not found in message {self._desc.full_name}'
461462
raise CompilationError(msg)
462463
self._oneofs.append(MessageOneofRule(fields, rule.required))
463464

tests/validate_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def test_protovalidate_oneof_unknown_field_name(self):
8888
msg = validations_pb2.ProtovalidateOneofUnknownFieldName()
8989
with self.assertRaises(protovalidate.CompilationError) as cm:
9090
protovalidate.validate(msg)
91-
assert str(cm.exception) == "field \"xxx\" not found in message tests.example.v1.ProtovalidateOneofUnknownFieldName"
91+
assert (
92+
str(cm.exception) == 'field "xxx" not found in message tests.example.v1.ProtovalidateOneofUnknownFieldName'
93+
)
9294

9395
def test_repeated(self):
9496
msg = validations_pb2.RepeatedEmbedSkip()

0 commit comments

Comments
 (0)