Skip to content

Commit

Permalink
Fix typing for mutable clients and services
Browse files Browse the repository at this point in the history
Summary: Fix typing for mutable services and clients

Reviewed By: createdbysk

Differential Revision: D66961800

fbshipit-source-id: fb27dbf93e01641c5993e5bf7cc4bb764bffb550
  • Loading branch information
yoney authored and facebook-github-bot committed Dec 9, 2024
1 parent a572167 commit 86dcd4f
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
}}{{!
This is the struct that wraps function secondary return type (ie. stream, sink)
}}{{#function:stream?}}{{!
}}{{program:module_mangle}}__thrift_types._fbthrift_{{service:name}}_{{function:name}}_result_stream{{!
}}{{program:module_mangle}}__{{> types/types_import_path}}._fbthrift_{{service:name}}_{{function:name}}_result_stream{{!
}}{{/function:stream?}}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ class _fbthrift_{{service:name}}_{{function:name}}_result({{> types/struct_base
{{#function:stream?}}


class _fbthrift_{{service:name}}_{{function:name}}_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[{{#function:stream_elem_type}}{{> types/pep484_type }}{{/function:stream_elem_type}}]):
class _fbthrift_{{service:name}}_{{function:name}}_result_stream({{!
}}{{#program:generate_mutable_types}}_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult{{/program:generate_mutable_types}}{{!
}}{{#program:generate_immutable_types}}_fbthrift_python_types._fbthrift_ResponseStreamResult{{/program:generate_immutable_types}}{{!
}}[{{#function:stream_elem_type}}{{> types/pep484_type }}{{/function:stream_elem_type}}]):
{{#function:stream_exceptions}}
{{field:py_name}}: _typing.Final[{{#field:type}}{{> types/pep484_type}}{{/field:type}}]
{{/function:stream_exceptions}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def serialize(
"MyService",
"serialize",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyService_serialize_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyService_serialize_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyService_serialize_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyService_serialize_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyService_serialize_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Factory,
interaction_name="SerialInteraction",
Expand Down Expand Up @@ -290,7 +290,7 @@ async def truthify(
"MyService",
"MyInteraction.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteraction_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteraction",
Expand Down Expand Up @@ -397,7 +397,7 @@ async def truthify(
"MyService",
"MyInteractionFast.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteractionFast_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteractionFast",
Expand Down Expand Up @@ -591,7 +591,7 @@ async def serialize(
"Factories",
"serialize",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_Factories_serialize_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_Factories_serialize_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_Factories_serialize_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_Factories_serialize_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_Factories_serialize_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Factory,
interaction_name="SerialInteraction",
Expand Down Expand Up @@ -746,7 +746,7 @@ async def truthify(
"Factories",
"MyInteraction.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteraction_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteraction",
Expand Down Expand Up @@ -853,7 +853,7 @@ async def truthify(
"Factories",
"MyInteractionFast.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteractionFast_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteractionFast",
Expand Down Expand Up @@ -1124,7 +1124,7 @@ async def truthify(
"Perform",
"MyInteraction.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteraction_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteraction",
Expand Down Expand Up @@ -1231,7 +1231,7 @@ async def truthify(
"Perform",
"MyInteractionFast.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteractionFast_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteractionFast_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteractionFast",
Expand Down Expand Up @@ -1508,7 +1508,7 @@ async def truthify(
"InteractWithShared",
"MyInteraction.truthify",
_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_args(),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyInteraction_truthify_result_stream),
(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result, _fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyInteraction_truthify_result_stream),
qualifier = _fbthrift_FunctionQualifier.Unspecified,
interaction_position=_fbthrift_InteractionMethodPosition.Member,
interaction_name="MyInteraction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def serialize(

async def _fbthrift__stream_wrapper_serialize(self, stream_generator: _typing.AsyncIterator[int], protocol: Protocol) -> _typing.AsyncIterator[_fbthrift_iobuf.IOBuf]:
async for item in stream_generator:
yield serialize_iobuf(_fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_MyService_serialize_result_stream(success=item), protocol)
yield serialize_iobuf(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyService_serialize_result_stream(success=item), protocol)

async def _fbthrift__handler_serialize(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) -> _typing.Tuple[_fbthrift_iobuf.IOBuf, _typing.AsyncIterator[_fbthrift_iobuf.IOBuf]]:
args_struct = deserialize(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_MyService_serialize_args, args, protocol)
Expand Down Expand Up @@ -186,7 +186,7 @@ async def serialize(

async def _fbthrift__stream_wrapper_serialize(self, stream_generator: _typing.AsyncIterator[int], protocol: Protocol) -> _typing.AsyncIterator[_fbthrift_iobuf.IOBuf]:
async for item in stream_generator:
yield serialize_iobuf(_fbthrift__test__fixtures__interactions__module__thrift_types._fbthrift_Factories_serialize_result_stream(success=item), protocol)
yield serialize_iobuf(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_Factories_serialize_result_stream(success=item), protocol)

async def _fbthrift__handler_serialize(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) -> _typing.Tuple[_fbthrift_iobuf.IOBuf, _typing.AsyncIterator[_fbthrift_iobuf.IOBuf]]:
args_struct = deserialize(_fbthrift__test__fixtures__interactions__module__thrift_mutable_types._fbthrift_Factories_serialize_args, args, protocol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class _fbthrift_MyService_serialize_result(_fbthrift_python_mutable_types.Mutabl
]]]: ...


class _fbthrift_MyService_serialize_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[int]):
class _fbthrift_MyService_serialize_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[int]):

def __init__(
self, *, success: _typing.Optional[int] = ...
Expand Down Expand Up @@ -263,7 +263,7 @@ class _fbthrift_MyInteraction_truthify_result(_fbthrift_python_mutable_types.Mut
]]]: ...


class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down Expand Up @@ -337,7 +337,7 @@ class _fbthrift_MyInteractionFast_truthify_result(_fbthrift_python_mutable_types
]]]: ...


class _fbthrift_MyInteractionFast_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteractionFast_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down Expand Up @@ -477,7 +477,7 @@ class _fbthrift_Factories_serialize_result(_fbthrift_python_mutable_types.Mutabl
]]]: ...


class _fbthrift_Factories_serialize_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[int]):
class _fbthrift_Factories_serialize_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[int]):

def __init__(
self, *, success: _typing.Optional[int] = ...
Expand Down Expand Up @@ -553,7 +553,7 @@ class _fbthrift_MyInteraction_truthify_result(_fbthrift_python_mutable_types.Mut
]]]: ...


class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down Expand Up @@ -627,7 +627,7 @@ class _fbthrift_MyInteractionFast_truthify_result(_fbthrift_python_mutable_types
]]]: ...


class _fbthrift_MyInteractionFast_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteractionFast_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down Expand Up @@ -753,7 +753,7 @@ class _fbthrift_MyInteraction_truthify_result(_fbthrift_python_mutable_types.Mut
]]]: ...


class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down Expand Up @@ -827,7 +827,7 @@ class _fbthrift_MyInteractionFast_truthify_result(_fbthrift_python_mutable_types
]]]: ...


class _fbthrift_MyInteractionFast_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteractionFast_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down Expand Up @@ -953,7 +953,7 @@ class _fbthrift_MyInteraction_truthify_result(_fbthrift_python_mutable_types.Mut
]]]: ...


class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[bool]):
class _fbthrift_MyInteraction_truthify_result_stream(_fbthrift_python_mutable_types._fbthrift_MutableResponseStreamResult[bool]):

def __init__(
self, *, success: _typing.Optional[bool] = ...
Expand Down
Loading

0 comments on commit 86dcd4f

Please sign in to comment.