From ea0a37c8b97bf7bc997e3bdafbbff29058758b81 Mon Sep 17 00:00:00 2001 From: Anas Khan <83116240+anxkhn@users.noreply.github.com> Date: Sat, 4 Jul 2026 18:17:43 +0530 Subject: [PATCH] fix(bigtable): correct get_bigtable_data_client return annotation The return annotation referenced bigtable.BigtableDataClient, but that name is not exported from the google.cloud.bigtable top-level namespace (only Client is). The client is constructed from google.cloud.bigtable.data, which is where BigtableDataClient actually lives and is already imported. Because of "from __future__ import annotations" the annotation is a lazy string, so it does not fail at runtime, but typing.get_type_hints() and doc tooling raise AttributeError when resolving it. Point the annotation at data.BigtableDataClient (the type actually returned) and add a regression test that get_type_hints() resolves it. --- src/google/adk/tools/bigtable/client.py | 2 +- tests/unittests/tools/bigtable/test_client.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/google/adk/tools/bigtable/client.py b/src/google/adk/tools/bigtable/client.py index 204e2756d94..1d1dd417a98 100644 --- a/src/google/adk/tools/bigtable/client.py +++ b/src/google/adk/tools/bigtable/client.py @@ -31,7 +31,7 @@ def _get_client_info() -> google.api_core.client_info.ClientInfo: def get_bigtable_data_client( *, project: str, credentials: Credentials -) -> bigtable.BigtableDataClient: +) -> data.BigtableDataClient: """Get a Bigtable client.""" bigtable_data_client = data.BigtableDataClient( diff --git a/tests/unittests/tools/bigtable/test_client.py b/tests/unittests/tools/bigtable/test_client.py index 533d5ee331d..3f48a688745 100644 --- a/tests/unittests/tools/bigtable/test_client.py +++ b/tests/unittests/tools/bigtable/test_client.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import typing from unittest import mock from google.adk.tools.bigtable import client from google.auth.credentials import Credentials +from google.cloud.bigtable import data def test_get_bigtable_data_client(): @@ -48,3 +50,9 @@ def test_get_bigtable_admin_client(): credentials=mock_creds, client_info=mock.ANY, ) + + +def test_get_bigtable_data_client_return_annotation_resolves(): + """The data client return annotation must resolve to a real type.""" + hints = typing.get_type_hints(client.get_bigtable_data_client) + assert hints["return"] is data.BigtableDataClient