Skip to content

Commit

Permalink
fix(sdk): fix to support python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousben committed Dec 17, 2024
1 parent b6815dc commit c0783d2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python-sdk/indexify/function_executor/proto/message_validator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Self
from typing import Any

from .function_executor_pb2 import SerializedObject

Expand All @@ -7,21 +7,21 @@ class MessageValidator:
def __init__(self, message: Any):
self._message = message

def required_field(self, field_name: str) -> Self:
def required_field(self, field_name: str) -> "MessageValidator":
if not self._message.HasField(field_name):
raise ValueError(
f"Field '{field_name}' is required in {type(self._message).__name__}"
)
return self

def required_serialized_object(self, field_name: str) -> Self:
def required_serialized_object(self, field_name: str) -> "MessageValidator":
"""Validates the SerializedObject.
Raises: ValueError: If the SerializedObject is invalid or not present."""
self.required_field(field_name)
return self.optional_serialized_object(field_name)

def optional_serialized_object(self, field_name: str) -> Self:
def optional_serialized_object(self, field_name: str) -> "MessageValidator":
"""Validates the SerializedObject.
Raises: ValueError: If the SerializedObject is invalid."""
Expand All @@ -32,7 +32,7 @@ def optional_serialized_object(self, field_name: str) -> Self:
if not serializedObject.HasField("string") and not serializedObject.HasField(
"bytes"
):
raise ValueError("oneof 'data' is requred in SerializedObject")
raise ValueError("oneof 'data' is required in SerializedObject")
if not serializedObject.HasField("content_type"):
raise ValueError("Field 'content_type' is requred in SerializedObject")
raise ValueError("Field 'content_type' is required in SerializedObject")
return self

0 comments on commit c0783d2

Please sign in to comment.