From 4025e4a6c84fb2fc8756472e1b2de95929534497 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Fri, 8 May 2026 09:25:48 -0400 Subject: [PATCH] Make Rules an ABC Not sure why I thought this would be trickier. Ref: https://github.com/bufbuild/protovalidate-python/pull/465#discussion_r3202126421 --- protovalidate/internal/rules.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/protovalidate/internal/rules.py b/protovalidate/internal/rules.py index 2cf6a16..80f9b68 100644 --- a/protovalidate/internal/rules.py +++ b/protovalidate/internal/rules.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import abc import dataclasses import datetime import typing @@ -320,12 +321,13 @@ def sub_context(self) -> "RuleContext": return RuleContext(fail_fast=self._fail_fast) -class Rules: +class Rules(abc.ABC): """The rules associated with a single 'rules' message.""" - def validate(self, ctx: RuleContext, message: message.Message): # noqa: ARG002 + @abc.abstractmethod + def validate(self, ctx: RuleContext, message: message.Message) -> None: """Validate the message against the rules in this rule.""" - ctx.add(Violation(rule_id="unimplemented", message="Unimplemented")) + ... @dataclasses.dataclass