Skip to content

Commit ea0a37c

Browse files
committed
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.
1 parent 68a7803 commit ea0a37c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/google/adk/tools/bigtable/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _get_client_info() -> google.api_core.client_info.ClientInfo:
3131

3232
def get_bigtable_data_client(
3333
*, project: str, credentials: Credentials
34-
) -> bigtable.BigtableDataClient:
34+
) -> data.BigtableDataClient:
3535
"""Get a Bigtable client."""
3636

3737
bigtable_data_client = data.BigtableDataClient(

tests/unittests/tools/bigtable/test_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import typing
1516
from unittest import mock
1617

1718
from google.adk.tools.bigtable import client
1819
from google.auth.credentials import Credentials
20+
from google.cloud.bigtable import data
1921

2022

2123
def test_get_bigtable_data_client():
@@ -48,3 +50,9 @@ def test_get_bigtable_admin_client():
4850
credentials=mock_creds,
4951
client_info=mock.ANY,
5052
)
53+
54+
55+
def test_get_bigtable_data_client_return_annotation_resolves():
56+
"""The data client return annotation must resolve to a real type."""
57+
hints = typing.get_type_hints(client.get_bigtable_data_client)
58+
assert hints["return"] is data.BigtableDataClient

0 commit comments

Comments
 (0)