From b00e4f58c14aac44de2bde10222d5af656d18203 Mon Sep 17 00:00:00 2001 From: TJ Yin Date: Mon, 16 Dec 2024 05:06:44 -0800 Subject: [PATCH] Add the ability to apply python patch to a mutable struct Reviewed By: yoney Differential Revision: D67049001 fbshipit-source-id: 51459e58ef530ba60bf3550e0223df77c4ea623e --- thrift/lib/python/mutable_types.pyi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/thrift/lib/python/mutable_types.pyi b/thrift/lib/python/mutable_types.pyi index 717cfc096d8..6a23b8282a3 100644 --- a/thrift/lib/python/mutable_types.pyi +++ b/thrift/lib/python/mutable_types.pyi @@ -17,6 +17,7 @@ import typing from thrift.python.exceptions import Error +from thrift.python.types import Struct # Base class for mutable structs and mutable unions class MutableStructOrUnion: @@ -28,7 +29,14 @@ class MutableStructOrUnion: class MutableStructMeta(type): ... class MutableUnionMeta(type): ... class MutableGeneratedError(Error): ... -class MutableStruct(MutableStructOrUnion, metaclass=MutableStructMeta): ... + +class MutableStruct( + MutableStructOrUnion, + typing.Iterable[typing.Tuple[str, typing.Any]], + metaclass=MutableStructMeta, +): + def _to_python(self) -> Struct: ... + class MutableUnion(MutableStructOrUnion, metaclass=MutableUnionMeta): ... MutableStructOrError = typing.Union[MutableStruct, MutableGeneratedError]