encodable.py: Add type annotations.

PiperOrigin-RevId: 772024516
This commit is contained in:
Kurt Schwehr 2025-06-16 07:50:25 -07:00 committed by Google Earth Engine Authors
parent 694999d1b9
commit 66a76f80da

View File

@ -1,10 +1,12 @@
"""Interfaces implemented by serializable objects."""
from typing import Any, Callable
class Encodable:
"""An interface implemented by objects that can serialize themselves."""
def encode(self, encoder):
def encode(self, encoder: Callable[[Any], Any]) -> Any:
"""Encodes the object in a format compatible with Serializer.
Args:
@ -16,7 +18,7 @@ class Encodable:
"""
raise NotImplementedError('Encodable classes must implement encode().')
def encode_cloud_value(self, encoder):
def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> Any:
"""Encodes the object as a ValueNode.
Args:
@ -33,7 +35,7 @@ class Encodable:
class EncodableFunction:
"""An interface implemented by functions that can serialize themselves."""
def encode_invocation(self, encoder):
def encode_invocation(self, encoder: Callable[[Any], Any]) -> Any:
"""Encodes the function in a format compatible with Serializer.
Args:
@ -46,7 +48,7 @@ class EncodableFunction:
raise NotImplementedError(
'EncodableFunction classes must implement encode_invocation().')
def encode_cloud_invocation(self, encoder):
def encode_cloud_invocation(self, encoder: Callable[[Any], Any]) -> Any:
"""Encodes the function as a FunctionInvocation.
Args: