Skip to content

Commit 139cedd

Browse files
author
John Chadwick
committed
Make CelRunner a dataclass
1 parent ca2f727 commit 139cedd

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

protovalidate/internal/constraints.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import dataclasses
1516
import datetime
1617
import typing
1718

@@ -293,27 +294,13 @@ def validate(self, ctx: ConstraintContext, message: message.Message): # noqa: A
293294
ctx.add(Violation(constraint_id="unimplemented", message="Unimplemented"))
294295

295296

297+
@dataclasses.dataclass
296298
class CelRunner:
297299
runner: celpy.Runner
298300
constraint: validate_pb2.Constraint
299-
rule_value: typing.Optional[typing.Any]
300-
rule_cel: typing.Optional[celtypes.Value]
301-
rule_path: typing.Optional[validate_pb2.FieldPath]
302-
303-
def __init__(
304-
self,
305-
*,
306-
runner: celpy.Runner,
307-
constraint: validate_pb2.Constraint,
308-
rule_value: typing.Optional[typing.Any] = None,
309-
rule_cel: typing.Optional[celtypes.Value] = None,
310-
rule_path: typing.Optional[validate_pb2.FieldPath] = None,
311-
):
312-
self.runner = runner
313-
self.constraint = constraint
314-
self.rule_value = rule_value
315-
self.rule_cel = rule_cel
316-
self.rule_path = rule_path
301+
rule_value: typing.Optional[typing.Any] = None
302+
rule_cel: typing.Optional[celtypes.Value] = None
303+
rule_path: typing.Optional[validate_pb2.FieldPath] = None
317304

318305

319306
class CelConstraintRules(ConstraintRules):

0 commit comments

Comments
 (0)