Skip to content

Commit

Permalink
Fix mutable thrift-python clients/services
Browse files Browse the repository at this point in the history
Summary:
- Add missing imports
- Fix the struct base in stub file, use MutableStruct for mutable types

Reviewed By: createdbysk

Differential Revision: D66956492

fbshipit-source-id: bb11ec6c25c7bca41d58975814738f19268638f1
  • Loading branch information
yoney authored and facebook-github-bot committed Dec 9, 2024
1 parent f63b3d9 commit 6000643
Show file tree
Hide file tree
Showing 51 changed files with 308 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ from {{program:base_library_package}}.client import (
from {{program:base_library_package}}.client.omni_client import InteractionMethodPosition as _fbthrift_InteractionMethodPosition, FunctionQualifier as _fbthrift_FunctionQualifier
from {{program:base_library_package}}.common import RpcOptions{{!
}}{{#program:generate_mutable_types}}
import {{program:base_library_package}}.mutable_containers as _fbthrift_python_mutable_containers
import {{program:base_library_package}}.mutable_exceptions as _fbthrift_python_mutable_exceptions
import {{program:base_library_package}}.mutable_types as _fbthrift_python_mutable_types{{!
}}{{/program:generate_mutable_types}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import apache.thrift.metadata.thrift_types as _fbthrift_metadata
from {{program:base_library_package}}.serializer import serialize_iobuf, deserialize, Protocol
{{/program:generate_immutable_types}}
{{#program:generate_mutable_types}}
import {{program:base_library_package}}.mutable_containers as _fbthrift_python_mutable_containers
from {{program:base_library_package}}.mutable_serializer import serialize_iobuf, deserialize, Protocol
{{/program:generate_mutable_types}}
from {{program:base_library_package}}.server import ServiceInterface, RpcKind, PythonUserException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The argument and result types for functions on thrift services (and interactions
}}{{#service:supported_functions}}


class {{> types/function_args_type}}(_fbthrift_python_types.Struct):
class {{> types/function_args_type}}({{> types/struct_base }}):
{{#function:args}}
{{field:py_name}}: _typing.Final[{{#field:type}}{{> types/pep484_type}}{{/field:type}}] = ...
{{/function:args}}
Expand All @@ -37,7 +37,7 @@ class {{> types/function_args_type}}(_fbthrift_python_types.Struct):
{{^function:oneway?}}


class _fbthrift_{{service:name}}_{{function:name}}_result(_fbthrift_python_types.Struct):
class _fbthrift_{{service:name}}_{{function:name}}_result({{> types/struct_base }}):
{{#function:regular_response_type}}
success: _typing.Final[{{> types/pep484_type }}]
{{/function:regular_response_type}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
)
from thrift.python.client.omni_client import InteractionMethodPosition as _fbthrift_InteractionMethodPosition, FunctionQualifier as _fbthrift_FunctionQualifier
from thrift.python.common import RpcOptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.exceptions as _fbthrift_python_exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import folly.iobuf as _fbthrift_iobuf

import apache.thrift.metadata.thrift_types as _fbthrift_metadata
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers
from thrift.python.mutable_serializer import serialize_iobuf, deserialize, Protocol
from thrift.python.server import ServiceInterface, RpcKind, PythonUserException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ MyEnumAlias = _fbthrift_current_module.MyEnum
MyDataItemAlias = _fbthrift_current_module.MyDataItem


class _fbthrift_FooService_simple_rpc_args(_fbthrift_python_types.Struct):
class _fbthrift_FooService_simple_rpc_args(_fbthrift_python_mutable_types.MutableStruct):

def __init__(
self,
Expand All @@ -424,7 +424,7 @@ class _fbthrift_FooService_simple_rpc_args(_fbthrift_python_types.Struct):
_typing.Union[None]]]: ...


class _fbthrift_FooService_simple_rpc_result(_fbthrift_python_types.Struct):
class _fbthrift_FooService_simple_rpc_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[None]

def __init__(
Expand All @@ -438,7 +438,7 @@ class _fbthrift_FooService_simple_rpc_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_FB303Service_simple_rpc_args(_fbthrift_python_types.Struct):
class _fbthrift_FB303Service_simple_rpc_args(_fbthrift_python_mutable_types.MutableStruct):
int_parameter: _typing.Final[int] = ...

def __init__(
Expand All @@ -451,7 +451,7 @@ class _fbthrift_FB303Service_simple_rpc_args(_fbthrift_python_types.Struct):
_typing.Union[None, int]]]: ...


class _fbthrift_FB303Service_simple_rpc_result(_fbthrift_python_types.Struct):
class _fbthrift_FB303Service_simple_rpc_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[_fbthrift_current_module.ReservedKeyword]

def __init__(
Expand All @@ -465,7 +465,7 @@ class _fbthrift_FB303Service_simple_rpc_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_ping_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_ping_args(_fbthrift_python_mutable_types.MutableStruct):

def __init__(
self,
Expand All @@ -476,7 +476,7 @@ class _fbthrift_MyService_ping_args(_fbthrift_python_types.Struct):
_typing.Union[None]]]: ...


class _fbthrift_MyService_ping_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_ping_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[None]

def __init__(
Expand All @@ -490,7 +490,7 @@ class _fbthrift_MyService_ping_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_getRandomData_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_getRandomData_args(_fbthrift_python_mutable_types.MutableStruct):

def __init__(
self,
Expand All @@ -501,7 +501,7 @@ class _fbthrift_MyService_getRandomData_args(_fbthrift_python_types.Struct):
_typing.Union[None]]]: ...


class _fbthrift_MyService_getRandomData_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_getRandomData_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[str]

def __init__(
Expand All @@ -515,7 +515,7 @@ class _fbthrift_MyService_getRandomData_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_sink_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_sink_args(_fbthrift_python_mutable_types.MutableStruct):
sink: _typing.Final[int] = ...

def __init__(
Expand All @@ -528,7 +528,7 @@ class _fbthrift_MyService_sink_args(_fbthrift_python_types.Struct):
_typing.Union[None, int]]]: ...


class _fbthrift_MyService_sink_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_sink_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[None]

def __init__(
Expand All @@ -542,7 +542,7 @@ class _fbthrift_MyService_sink_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_putDataById_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_putDataById_args(_fbthrift_python_mutable_types.MutableStruct):
id: _typing.Final[int] = ...
data: _typing.Final[str] = ...

Expand All @@ -557,7 +557,7 @@ class _fbthrift_MyService_putDataById_args(_fbthrift_python_types.Struct):
_typing.Union[None, int, str]]]: ...


class _fbthrift_MyService_putDataById_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_putDataById_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[None]

def __init__(
Expand All @@ -571,7 +571,7 @@ class _fbthrift_MyService_putDataById_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_hasDataById_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_hasDataById_args(_fbthrift_python_mutable_types.MutableStruct):
id: _typing.Final[int] = ...

def __init__(
Expand All @@ -584,7 +584,7 @@ class _fbthrift_MyService_hasDataById_args(_fbthrift_python_types.Struct):
_typing.Union[None, int]]]: ...


class _fbthrift_MyService_hasDataById_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_hasDataById_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[bool]

def __init__(
Expand All @@ -598,7 +598,7 @@ class _fbthrift_MyService_hasDataById_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_getDataById_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_getDataById_args(_fbthrift_python_mutable_types.MutableStruct):
id: _typing.Final[int] = ...

def __init__(
Expand All @@ -611,7 +611,7 @@ class _fbthrift_MyService_getDataById_args(_fbthrift_python_types.Struct):
_typing.Union[None, int]]]: ...


class _fbthrift_MyService_getDataById_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_getDataById_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[str]

def __init__(
Expand All @@ -625,7 +625,7 @@ class _fbthrift_MyService_getDataById_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_deleteDataById_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_deleteDataById_args(_fbthrift_python_mutable_types.MutableStruct):
id: _typing.Final[int] = ...

def __init__(
Expand All @@ -638,7 +638,7 @@ class _fbthrift_MyService_deleteDataById_args(_fbthrift_python_types.Struct):
_typing.Union[None, int]]]: ...


class _fbthrift_MyService_deleteDataById_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_deleteDataById_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[None]

def __init__(
Expand All @@ -652,7 +652,7 @@ class _fbthrift_MyService_deleteDataById_result(_fbthrift_python_types.Struct):
]]]: ...


class _fbthrift_MyService_lobDataById_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_lobDataById_args(_fbthrift_python_mutable_types.MutableStruct):
id: _typing.Final[int] = ...
data: _typing.Final[str] = ...

Expand All @@ -667,7 +667,7 @@ class _fbthrift_MyService_lobDataById_args(_fbthrift_python_types.Struct):
_typing.Union[None, int, str]]]: ...


class _fbthrift_MyService_invalid_return_for_hack_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_invalid_return_for_hack_args(_fbthrift_python_mutable_types.MutableStruct):

def __init__(
self,
Expand All @@ -678,7 +678,7 @@ class _fbthrift_MyService_invalid_return_for_hack_args(_fbthrift_python_types.St
_typing.Union[None]]]: ...


class _fbthrift_MyService_invalid_return_for_hack_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_invalid_return_for_hack_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[_fbthrift_python_mutable_containers.MutableSet[float]]

def __init__(
Expand All @@ -692,7 +692,7 @@ class _fbthrift_MyService_invalid_return_for_hack_result(_fbthrift_python_types.
]]]: ...


class _fbthrift_MyService_rpc_skipped_codegen_args(_fbthrift_python_types.Struct):
class _fbthrift_MyService_rpc_skipped_codegen_args(_fbthrift_python_mutable_types.MutableStruct):

def __init__(
self,
Expand All @@ -703,7 +703,7 @@ class _fbthrift_MyService_rpc_skipped_codegen_args(_fbthrift_python_types.Struct
_typing.Union[None]]]: ...


class _fbthrift_MyService_rpc_skipped_codegen_result(_fbthrift_python_types.Struct):
class _fbthrift_MyService_rpc_skipped_codegen_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[None]

def __init__(
Expand All @@ -717,7 +717,7 @@ class _fbthrift_MyService_rpc_skipped_codegen_result(_fbthrift_python_types.Stru
]]]: ...


class _fbthrift_DbMixedStackArguments_getDataByKey0_args(_fbthrift_python_types.Struct):
class _fbthrift_DbMixedStackArguments_getDataByKey0_args(_fbthrift_python_mutable_types.MutableStruct):
key: _typing.Final[str] = ...

def __init__(
Expand All @@ -730,7 +730,7 @@ class _fbthrift_DbMixedStackArguments_getDataByKey0_args(_fbthrift_python_types.
_typing.Union[None, str]]]: ...


class _fbthrift_DbMixedStackArguments_getDataByKey0_result(_fbthrift_python_types.Struct):
class _fbthrift_DbMixedStackArguments_getDataByKey0_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[bytes]

def __init__(
Expand All @@ -744,7 +744,7 @@ class _fbthrift_DbMixedStackArguments_getDataByKey0_result(_fbthrift_python_type
]]]: ...


class _fbthrift_DbMixedStackArguments_getDataByKey1_args(_fbthrift_python_types.Struct):
class _fbthrift_DbMixedStackArguments_getDataByKey1_args(_fbthrift_python_mutable_types.MutableStruct):
key: _typing.Final[str] = ...

def __init__(
Expand All @@ -757,7 +757,7 @@ class _fbthrift_DbMixedStackArguments_getDataByKey1_args(_fbthrift_python_types.
_typing.Union[None, str]]]: ...


class _fbthrift_DbMixedStackArguments_getDataByKey1_result(_fbthrift_python_types.Struct):
class _fbthrift_DbMixedStackArguments_getDataByKey1_result(_fbthrift_python_mutable_types.MutableStruct):
success: _typing.Final[bytes]

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
)
from thrift.python.client.omni_client import InteractionMethodPosition as _fbthrift_InteractionMethodPosition, FunctionQualifier as _fbthrift_FunctionQualifier
from thrift.python.common import RpcOptions
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers
import thrift.python.mutable_exceptions as _fbthrift_python_mutable_exceptions
import thrift.python.mutable_types as _fbthrift_python_mutable_types
import thrift.python.exceptions as _fbthrift_python_exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import folly.iobuf as _fbthrift_iobuf

import apache.thrift.metadata.thrift_types as _fbthrift_metadata
import thrift.python.mutable_containers as _fbthrift_python_mutable_containers
from thrift.python.mutable_serializer import serialize_iobuf, deserialize, Protocol
from thrift.python.server import ServiceInterface, RpcKind, PythonUserException

Expand Down
Loading

0 comments on commit 6000643

Please sign in to comment.