FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: fallback to unary_unary when wrapping async callables by daniel-sanche · Pull Request #653 · googleapis/python-api-core · GitHub

This repository was archived by the owner on Feb 23, 2026. It is now read-only.
/ python-api-core Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 3 additions & 4 deletions google/api_core/grpc_helpers_async.py
This file contains hidden or 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
Expand Up @@ -197,16 +197,15 @@ def wrap_errors(callable_):
Returns: Callable: The wrapped gRPC callable.
"""
grpc_helpers._patch_callable_name(callable_)
if isinstance(callable_, aio.UnaryUnaryMultiCallable):
return _wrap_unary_errors(callable_)
elif isinstance(callable_, aio.UnaryStreamMultiCallable):

if isinstance(callable_, aio.UnaryStreamMultiCallable):
return _wrap_stream_errors(callable_, _WrappedUnaryStreamCall)
elif isinstance(callable_, aio.StreamUnaryMultiCallable):
return _wrap_stream_errors(callable_, _WrappedStreamUnaryCall)
elif isinstance(callable_, aio.StreamStreamMultiCallable):
return _wrap_stream_errors(callable_, _WrappedStreamStreamCall)
else:
raise TypeError("Unexpected type of callable: {}".format(type(callable_)))
return _wrap_unary_errors(callable_)


def create_channel(
Expand Down
13 changes: 0 additions & 13 deletions tests/asyncio/test_grpc_helpers_async.py
This file contains hidden or 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
Expand Up @@ -165,19 +165,6 @@ async def test_wrap_stream_errors_stream_stream():
assert mock_call.wait_for_connection.call_count == 1


@pytest.mark.asyncio
async def test_wrap_errors_type_error():
"""
If wrap_errors is called with an unexpected type, it should raise a TypeError.
"""
mock_call = mock.Mock()
multicallable = mock.Mock(return_value=mock_call)

with pytest.raises(TypeError) as exc:
grpc_helpers_async.wrap_errors(multicallable)
assert "Unexpected type" in str(exc.value)


@pytest.mark.asyncio
async def test_wrap_stream_errors_raised():
grpc_error = RpcErrorImpl(grpc.StatusCode.INVALID_ARGUMENT)
Expand Down

Back | FazBrowse Home | New Git URL