Skip to content

Commit

Permalink
fix bugs in cmd options causing mutable fixtures to not be generated
Browse files Browse the repository at this point in the history
Summary: The `:` as delimiter caused this option to be ignored.

Reviewed By: aristidisp

Differential Revision: D67117362

fbshipit-source-id: 871a38bafac7b57db23c4e45c097f19ef231d28b
  • Loading branch information
ahilger authored and facebook-github-bot committed Dec 12, 2024
1 parent 8b44361 commit b36b7cd
Show file tree
Hide file tree
Showing 19 changed files with 8,158 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ go_extend: mstch_go src/extend.thrift
go_hsmodule: mstch_go src/hsmodule.thrift
go_emptyns: mstch_go src/emptyns.thrift
go_quoted: mstch_go src/quoted.thrift
python_experimental_generate_mutable_types: mstch_python:experimental_generate_mutable_types:root_module_prefix=python_module_root src/module.thrift
python_experimental_generate_mutable_types: mstch_python:experimental_generate_mutable_types,root_module_prefix=python_module_root src/module.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
import folly.iobuf as _fbthrift_iobuf
import thrift.python.abstract_types as _fbthrift_python_abstract_types

from my.namespacing.test.module.module.thrift_enums import *
from python_module_root.my.namespacing.test.module.module.thrift_enums import *
class Foo(_abc.ABC):
@_fbthrift_property
@_abc.abstractmethod
def MyInt(self) -> int: ...
@_abc.abstractmethod
def __iter__(self) -> _typing.Iterator[_typing.Tuple[str, _typing.Union[int]]]: ...
@_abc.abstractmethod
def _to_python(self) -> "my.namespacing.test.module.module.thrift_types.Foo": ... # type: ignore
def _to_mutable_python(self) -> "python_module_root.my.namespacing.test.module.module.thrift_mutable_types.Foo": ... # type: ignore
@_abc.abstractmethod
def _to_py3(self) -> "my.namespacing.test.module.module.types.Foo": ... # type: ignore
def _to_python(self) -> "python_module_root.my.namespacing.test.module.module.thrift_types.Foo": ... # type: ignore
@_abc.abstractmethod
def _to_py3(self) -> "python_module_root.my.namespacing.test.module.module.types.Foo": ... # type: ignore
@_abc.abstractmethod
def _to_py_deprecated(self) -> "my.namespacing.test.module.ttypes.Foo": ... # type: ignore
_fbthrift_Foo = Foo
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from thrift.python.common import RpcOptions
import thrift.python.exceptions as _fbthrift_python_exceptions
import thrift.python.types as _fbthrift_python_types
import my.namespacing.test.module.module.thrift_types as _fbthrift__my__namespacing__test__module__module__thrift_types
import my.namespacing.test.module.module.thrift_metadata
import python_module_root.my.namespacing.test.module.module.thrift_types as python_module_root__my__namespacing__test__module__module__thrift_types
import python_module_root.my.namespacing.test.module.module.thrift_metadata

class TestService(_fbthrift_python_Client["TestService.Async", "TestService.Sync"]):
@staticmethod
Expand All @@ -39,7 +39,7 @@ def __get_thrift_unstructured_annotations_DEPRECATED__() -> _typing.Mapping[str,

@staticmethod
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
return my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()
return python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

class Async(_fbthrift_python_AsyncClient):
@staticmethod
Expand All @@ -52,7 +52,7 @@ def __get_thrift_uri__() -> _typing.Optional[str]:

@staticmethod
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
return my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()
return python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

async def init(
self,
Expand All @@ -63,9 +63,9 @@ async def init(
_fbthrift_resp = await self._send_request(
"TestService",
"init",
_fbthrift__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_args(
python_module_root__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_args(
int1=int1,),
_fbthrift__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_result,
python_module_root__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_result,
qualifier = _fbthrift_FunctionQualifier.Unspecified,
uri_or_name="TestService",
rpc_options=rpc_options,
Expand All @@ -89,7 +89,7 @@ def __get_thrift_uri__() -> _typing.Optional[str]:

@staticmethod
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
return my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()
return python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

def init(
self,
Expand All @@ -100,9 +100,9 @@ def init(
_fbthrift_resp = self._send_request(
"TestService",
"init",
_fbthrift__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_args(
python_module_root__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_args(
int1=int1,),
_fbthrift__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_result,
python_module_root__my__namespacing__test__module__module__thrift_types._fbthrift_TestService_init_result,
uri_or_name="TestService",
rpc_options=rpc_options,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import apache.thrift.metadata.thrift_types as _fbthrift_metadata

import my.namespacing.test.module.module.thrift_enums as _fbthrift_current_module_enums
import my.namespacing.test.module.module.thrift_enums
import python_module_root.my.namespacing.test.module.module.thrift_enums as _fbthrift_current_module_enums
import python_module_root.my.namespacing.test.module.module.thrift_enums


# TODO (ffrancet): This general pattern can be optimized by using tuples and dicts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#
# 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 python_module_root.my.namespacing.test.module.module.thrift_mutable_types as python_module_root__my__namespacing__test__module__module__thrift_mutable_types
import python_module_root.my.namespacing.test.module.module.thrift_metadata

class TestService(_fbthrift_python_Client["TestService.Async", "TestService.Sync"]):
@staticmethod
def __get_thrift_name__() -> str:
return "module.TestService"

@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 python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

class Async(_fbthrift_python_AsyncClient):
@staticmethod
def __get_thrift_name__() -> str:
return "module.TestService"

@staticmethod
def __get_thrift_uri__() -> _typing.Optional[str]:
return None

@staticmethod
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
return python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

async def init(
self,
int1: int,
*,
rpc_options: _typing.Optional[RpcOptions] = None,
) -> int:
_fbthrift_resp = await self._send_request(
"TestService",
"init",
python_module_root__my__namespacing__test__module__module__thrift_mutable_types._fbthrift_TestService_init_args(
int1=int1,),
python_module_root__my__namespacing__test__module__module__thrift_mutable_types._fbthrift_TestService_init_result,
qualifier = _fbthrift_FunctionQualifier.Unspecified,
uri_or_name="TestService",
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",
)

class Sync(_fbthrift_python_SyncClient):
@staticmethod
def __get_thrift_name__() -> str:
return "module.TestService"

@staticmethod
def __get_thrift_uri__() -> _typing.Optional[str]:
return None

@staticmethod
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
return python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

def init(
self,
int1: int,
*,
rpc_options: _typing.Optional[RpcOptions] = None,
) -> int:
_fbthrift_resp = self._send_request(
"TestService",
"init",
python_module_root__my__namespacing__test__module__module__thrift_mutable_types._fbthrift_TestService_init_args(
int1=int1,),
python_module_root__my__namespacing__test__module__module__thrift_mutable_types._fbthrift_TestService_init_result,
uri_or_name="TestService",
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",
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# 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 python_module_root.my.namespacing.test.module.module.thrift_mutable_types as python_module_root__my__namespacing__test__module__module__thrift_mutable_types
import python_module_root.my.namespacing.test.module.module.thrift_metadata

class TestServiceInterface(
ServiceInterface,
metaclass=ABCMeta
):

@staticmethod
def service_name() -> bytes:
return b"TestService"

def getFunctionTable(self) -> _typing.Mapping[bytes, _typing.Callable[..., object]]:
functionTable = {
b"init": (RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE, self._fbthrift__handler_init),
}
return {**super().getFunctionTable(), **functionTable}

@staticmethod
def __get_thrift_name__() -> str:
return "module.TestService"

@staticmethod
def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
return python_module_root.my.namespacing.test.module.module.thrift_metadata.gen_metadata_service_TestService()

@staticmethod
def __get_metadata_service_response__() -> _fbthrift_metadata.ThriftServiceMetadataResponse:
return python_module_root.my.namespacing.test.module.module.thrift_metadata._fbthrift_metadata_service_response_TestService()



async def init(
self,
int1: int
) -> int:
raise NotImplementedError("async def init is not implemented")

async def _fbthrift__handler_init(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) -> _fbthrift_iobuf.IOBuf:
args_struct = deserialize(python_module_root__my__namespacing__test__module__module__thrift_mutable_types._fbthrift_TestService_init_args, args, protocol)
value = await self.init(args_struct.int1,)
return_struct = python_module_root__my__namespacing__test__module__module__thrift_mutable_types._fbthrift_TestService_init_result(success=value)
return serialize_iobuf(return_struct, protocol)

Loading

0 comments on commit b36b7cd

Please sign in to comment.