-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate mutable types alongside immutable types
Summary: Remove "experimental_generate_mutable_types" flag and generate mutable types alongside immutable types. Reviewed By: createdbysk Differential Revision: D66937883 fbshipit-source-id: 91413488ccf526f31c83eec25847956128c96272
- Loading branch information
1 parent
c4e8c04
commit 39502dd
Showing
107 changed files
with
39,994 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
...thrift/compiler/test/fixtures/adapter/out/python_a/gen-python/a/thrift_mutable_clients.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# | ||
# Autogenerated by Thrift | ||
# | ||
# DO NOT EDIT | ||
# @generated | ||
# | ||
|
||
from __future__ import annotations | ||
|
||
import typing as _typing | ||
|
||
import apache.thrift.metadata.thrift_types as _fbthrift_metadata | ||
import folly.iobuf as _fbthrift_iobuf | ||
from thrift.python.client import ( | ||
AsyncClient as _fbthrift_python_AsyncClient, | ||
SyncClient as _fbthrift_python_SyncClient, | ||
Client as _fbthrift_python_Client, | ||
) | ||
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 | ||
import thrift.python.types as _fbthrift_python_types | ||
import a.thrift_mutable_types as _fbthrift__a__thrift_mutable_types | ||
import a.thrift_metadata | ||
import b.thrift_mutable_types as _fbthrift__b__thrift_mutable_types | ||
import c.thrift_mutable_types as _fbthrift__c__thrift_mutable_types | ||
import three | ||
import two | ||
import one | ||
import typeshed_three | ||
import typeshed_two | ||
import typeshed_one | ||
|
||
class MyService(_fbthrift_python_Client["MyService.Async", "MyService.Sync"]): | ||
@staticmethod | ||
def __get_thrift_name__() -> str: | ||
return "a.MyService" | ||
|
||
@staticmethod | ||
def __get_thrift_uri__() -> _typing.Optional[str]: | ||
return None | ||
|
||
@staticmethod | ||
def __get_thrift_unstructured_annotations_DEPRECATED__() -> _typing.Mapping[str, str]: | ||
return { | ||
} | ||
|
||
@staticmethod | ||
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: | ||
return a.thrift_metadata.gen_metadata_service_MyService() | ||
|
||
class Async(_fbthrift_python_AsyncClient): | ||
@staticmethod | ||
def __get_thrift_name__() -> str: | ||
return "a.MyService" | ||
|
||
@staticmethod | ||
def __get_thrift_uri__() -> _typing.Optional[str]: | ||
return None | ||
|
||
@staticmethod | ||
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: | ||
return a.thrift_metadata.gen_metadata_service_MyService() | ||
|
||
async def adapted_return( | ||
self, | ||
*, | ||
rpc_options: _typing.Optional[RpcOptions] = None, | ||
) -> typeshed_one.AdapterOneType[_fbthrift__b__thrift_mutable_types.B]: | ||
_fbthrift_resp = await self._send_request( | ||
"MyService", | ||
"adapted_return", | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_return_args(), | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_return_result, | ||
qualifier = _fbthrift_FunctionQualifier.Unspecified, | ||
uri_or_name="MyService", | ||
rpc_options=rpc_options, | ||
is_mutable_types=True, | ||
) | ||
# shortcut to success path for non-void returns | ||
if _fbthrift_resp.success is not None: | ||
return _fbthrift_resp.success | ||
raise _fbthrift_python_exceptions.ApplicationError( | ||
_fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT, | ||
"Empty Response", | ||
) | ||
|
||
async def adapted_param( | ||
self, | ||
param: typeshed_two.AdapterTwoType[_fbthrift__c__thrift_mutable_types.C2], | ||
*, | ||
rpc_options: _typing.Optional[RpcOptions] = None, | ||
) -> None: | ||
_fbthrift_resp = await self._send_request( | ||
"MyService", | ||
"adapted_param", | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_param_args( | ||
param=param,), | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_param_result, | ||
qualifier = _fbthrift_FunctionQualifier.Unspecified, | ||
uri_or_name="MyService", | ||
rpc_options=rpc_options, | ||
is_mutable_types=True, | ||
) | ||
|
||
|
||
# pyre-ignore[4]: Missing annotation. | ||
adapted_return = Async.adapted_return | ||
# pyre-ignore[4]: Missing annotation. | ||
adapted_param = Async.adapted_param | ||
|
||
class Sync(_fbthrift_python_SyncClient): | ||
@staticmethod | ||
def __get_thrift_name__() -> str: | ||
return "a.MyService" | ||
|
||
@staticmethod | ||
def __get_thrift_uri__() -> _typing.Optional[str]: | ||
return None | ||
|
||
@staticmethod | ||
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: | ||
return a.thrift_metadata.gen_metadata_service_MyService() | ||
|
||
def adapted_return( | ||
self, | ||
*, | ||
rpc_options: _typing.Optional[RpcOptions] = None, | ||
) -> typeshed_one.AdapterOneType[_fbthrift__b__thrift_mutable_types.B]: | ||
_fbthrift_resp = self._send_request( | ||
"MyService", | ||
"adapted_return", | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_return_args(), | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_return_result, | ||
uri_or_name="MyService", | ||
rpc_options=rpc_options, | ||
is_mutable_types=True, | ||
) | ||
# shortcut to success path for non-void returns | ||
if _fbthrift_resp.success is not None: | ||
return _fbthrift_resp.success | ||
raise _fbthrift_python_exceptions.ApplicationError( | ||
_fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT, | ||
"Empty Response", | ||
) | ||
|
||
def adapted_param( | ||
self, | ||
param: typeshed_two.AdapterTwoType[_fbthrift__c__thrift_mutable_types.C2], | ||
*, | ||
rpc_options: _typing.Optional[RpcOptions] = None, | ||
) -> None: | ||
_fbthrift_resp = self._send_request( | ||
"MyService", | ||
"adapted_param", | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_param_args( | ||
param=param,), | ||
_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_param_result, | ||
uri_or_name="MyService", | ||
rpc_options=rpc_options, | ||
is_mutable_types=True, | ||
) | ||
|
84 changes: 84 additions & 0 deletions
84
...hrift/compiler/test/fixtures/adapter/out/python_a/gen-python/a/thrift_mutable_services.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# | ||
# Autogenerated by Thrift | ||
# | ||
# DO NOT EDIT | ||
# @generated | ||
# | ||
|
||
from __future__ import annotations | ||
|
||
from abc import ABCMeta | ||
import typing as _typing | ||
|
||
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 | ||
|
||
import a.thrift_mutable_types as _fbthrift__a__thrift_mutable_types | ||
import a.thrift_metadata | ||
import b.thrift_mutable_types as _fbthrift__b__thrift_mutable_types | ||
import c.thrift_mutable_types as _fbthrift__c__thrift_mutable_types | ||
import three | ||
import two | ||
import one | ||
import typeshed_three | ||
import typeshed_two | ||
import typeshed_one | ||
|
||
class MyServiceInterface( | ||
ServiceInterface, | ||
metaclass=ABCMeta | ||
): | ||
|
||
@staticmethod | ||
def service_name() -> bytes: | ||
return b"MyService" | ||
|
||
def getFunctionTable(self) -> _typing.Mapping[bytes, _typing.Callable[..., object]]: | ||
functionTable = { | ||
b"adapted_return": (RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE, self._fbthrift__handler_adapted_return), | ||
b"adapted_param": (RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE, self._fbthrift__handler_adapted_param), | ||
} | ||
return {**super().getFunctionTable(), **functionTable} | ||
|
||
@staticmethod | ||
def __get_thrift_name__() -> str: | ||
return "a.MyService" | ||
|
||
@staticmethod | ||
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: | ||
return a.thrift_metadata.gen_metadata_service_MyService() | ||
|
||
@staticmethod | ||
def __get_metadata_service_response__() -> _fbthrift_metadata.ThriftServiceMetadataResponse: | ||
return a.thrift_metadata._fbthrift_metadata_service_response_MyService() | ||
|
||
|
||
|
||
async def adapted_return( | ||
self | ||
) -> typeshed_one.AdapterOneType[_fbthrift__b__thrift_mutable_types.B]: | ||
raise NotImplementedError("async def adapted_return is not implemented") | ||
|
||
async def _fbthrift__handler_adapted_return(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) -> _fbthrift_iobuf.IOBuf: | ||
args_struct = deserialize(_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_return_args, args, protocol) | ||
value = await self.adapted_return() | ||
return_struct = _fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_return_result(success=value) | ||
return serialize_iobuf(return_struct, protocol) | ||
|
||
|
||
async def adapted_param( | ||
self, | ||
param: typeshed_two.AdapterTwoType[_fbthrift__c__thrift_mutable_types.C2] | ||
) -> None: | ||
raise NotImplementedError("async def adapted_param is not implemented") | ||
|
||
async def _fbthrift__handler_adapted_param(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) -> _fbthrift_iobuf.IOBuf: | ||
args_struct = deserialize(_fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_param_args, args, protocol) | ||
value = await self.adapted_param(args_struct.param,) | ||
return_struct = _fbthrift__a__thrift_mutable_types._fbthrift_MyService_adapted_param_result() | ||
return serialize_iobuf(return_struct, protocol) | ||
|
Oops, something went wrong.