From 121ad428a74bba6d91beb37daf3f7c0d07f80dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Mon, 29 Jun 2026 19:53:24 +0000 Subject: [PATCH 1/7] fix: include amended user agent in read client --- .../google/cloud/bigquery/client.py | 138 +++++++++++------- 1 file changed, 86 insertions(+), 52 deletions(-) diff --git a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py index 54c8886cd30e..983d4560e67b 100644 --- a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py +++ b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py @@ -14,11 +14,8 @@ """Client for interacting with the Google BigQuery API.""" -from __future__ import absolute_import -from __future__ import annotations -from __future__ import division +from __future__ import absolute_import, annotations, division -from collections import abc as collections_abc import copy import datetime import functools @@ -30,36 +27,39 @@ import os import tempfile import typing +import uuid +import warnings +from collections import abc as collections_abc from typing import ( + IO, Any, Callable, Dict, - IO, Iterable, - Mapping, List, + Mapping, Optional, Sequence, Tuple, Union, ) -import uuid -import warnings - -import requests - -from google import resumable_media # type: ignore -from google.resumable_media.requests import MultipartUpload # type: ignore -from google.resumable_media.requests import ResumableUpload import google.api_core.client_options import google.api_core.exceptions as core_exceptions -from google.api_core.iam import Policy +import google.cloud._helpers # type: ignore +import requests +from google import resumable_media # type: ignore from google.api_core import page_iterator from google.api_core import retry as retries -import google.cloud._helpers # type: ignore +from google.api_core.iam import Policy from google.cloud import exceptions # pytype: disable=import-error -from google.cloud.client import ClientWithProject # type: ignore # pytype: disable=import-error +from google.cloud.client import ( + ClientWithProject, # type: ignore # pytype: disable=import-error +) +from google.resumable_media.requests import ( + MultipartUpload, # type: ignore + ResumableUpload, +) try: from google.cloud.bigquery_storage_v1.services.big_query_read.client import ( @@ -70,29 +70,30 @@ from google.auth.credentials import Credentials -from google.cloud.bigquery._http import Connection -from google.cloud.bigquery import _job_helpers -from google.cloud.bigquery import _pandas_helpers -from google.cloud.bigquery import _versions_helpers -from google.cloud.bigquery import enums +from google.cloud.bigquery import ( + _job_helpers, + _pandas_helpers, + _versions_helpers, + enums, + job, +) from google.cloud.bigquery import exceptions as bq_exceptions -from google.cloud.bigquery import job -from google.cloud.bigquery._helpers import _get_sub_prop -from google.cloud.bigquery._helpers import _record_field_to_json -from google.cloud.bigquery._helpers import _str_or_none -from google.cloud.bigquery._helpers import _verify_job_config_type -from google.cloud.bigquery._helpers import _get_bigquery_host -from google.cloud.bigquery._helpers import _DEFAULT_HOST -from google.cloud.bigquery._helpers import _DEFAULT_HOST_TEMPLATE -from google.cloud.bigquery._helpers import _DEFAULT_UNIVERSE -from google.cloud.bigquery._helpers import _validate_universe -from google.cloud.bigquery._helpers import _get_client_universe -from google.cloud.bigquery._helpers import TimeoutType +from google.cloud.bigquery._helpers import ( + _DEFAULT_HOST, + _DEFAULT_HOST_TEMPLATE, + _DEFAULT_UNIVERSE, + TimeoutType, + _get_bigquery_host, + _get_client_universe, + _get_sub_prop, + _record_field_to_json, + _str_or_none, + _validate_universe, + _verify_job_config_type, +) +from google.cloud.bigquery._http import Connection from google.cloud.bigquery._job_helpers import make_job_id as _make_job_id -from google.cloud.bigquery.dataset import Dataset -from google.cloud.bigquery.dataset import DatasetListItem -from google.cloud.bigquery.dataset import DatasetReference - +from google.cloud.bigquery.dataset import Dataset, DatasetListItem, DatasetReference from google.cloud.bigquery.enums import AutoRowIDs, DatasetView, UpdateMode from google.cloud.bigquery.format_options import ParquetOptions from google.cloud.bigquery.job import ( @@ -105,27 +106,26 @@ QueryJob, QueryJobConfig, ) -from google.cloud.bigquery.model import Model -from google.cloud.bigquery.model import ModelReference -from google.cloud.bigquery.model import _model_arg_to_model_ref +from google.cloud.bigquery.model import Model, ModelReference, _model_arg_to_model_ref from google.cloud.bigquery.opentelemetry_tracing import create_span from google.cloud.bigquery.query import _QueryResults from google.cloud.bigquery.retry import ( + DEFAULT_GET_JOB_TIMEOUT, DEFAULT_JOB_RETRY, DEFAULT_RETRY, DEFAULT_TIMEOUT, - DEFAULT_GET_JOB_TIMEOUT, POLLING_DEFAULT_VALUE, ) -from google.cloud.bigquery.routine import Routine -from google.cloud.bigquery.routine import RoutineReference +from google.cloud.bigquery.routine import Routine, RoutineReference from google.cloud.bigquery.schema import SchemaField -from google.cloud.bigquery.table import _table_arg_to_table -from google.cloud.bigquery.table import _table_arg_to_table_ref -from google.cloud.bigquery.table import Table -from google.cloud.bigquery.table import TableListItem -from google.cloud.bigquery.table import TableReference -from google.cloud.bigquery.table import RowIterator +from google.cloud.bigquery.table import ( + RowIterator, + Table, + TableListItem, + TableReference, + _table_arg_to_table, + _table_arg_to_table_ref, +) pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import() pandas = ( @@ -621,11 +621,45 @@ def _ensure_bqstorage_client( ) return None - if bqstorage_client is None: # pragma: NO COVER + # Import here since it should be installed if the BQ Storage client is + # also installed. + import google.api_core.gapic_v1.client_info + + try: + import pandas_gbq + except ImportError: + pandas_gbq = None + + if pandas_gbq is None: + user_agent = "pandas-gbq/0.0.0" + else: + user_agent = f"pandas-gbq/{pandas_gbq.__version__}" + + if client_info is None: + amended_client_info = google.api_core.gapic_v1.client_info.ClientInfo( + user_agent=user_agent, + ) + else: + if client_info.user_agent is None: + amended_user_agent = user_agent + else: + amended_user_agent = client_info.user_agent + " " + user_agent + + amended_client_info = google.api_core.gapic_v1.client_info.ClientInfo( + python_version=client_info.python_version, + grpc_version=client_info.grpc_version, + api_core_version=client_info.api_core_version, + gapic_version=client_info.gapic_version, + user_agent=amended_user_agent, + rest_version=client_info.rest_version, + protobuf_runtime_version=client_info.protobuf_runtime_version, + ) + + if bqstorage_client is None: bqstorage_client = bigquery_storage.BigQueryReadClient( credentials=self._credentials, client_options=client_options, - client_info=client_info, # type: ignore # (None is also accepted) + client_info=amended_client_info, ) return bqstorage_client From 737f6957a1601aed550b188110f96be7ad1bb638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Mon, 29 Jun 2026 21:32:49 +0000 Subject: [PATCH 2/7] add unit tests --- packages/google-cloud-bigquery/noxfile.py | 4 +- .../tests/unit/test_client.py | 314 +++++++++++------- 2 files changed, 201 insertions(+), 117 deletions(-) diff --git a/packages/google-cloud-bigquery/noxfile.py b/packages/google-cloud-bigquery/noxfile.py index cfe3b60e0c51..c1dd1692b744 100644 --- a/packages/google-cloud-bigquery/noxfile.py +++ b/packages/google-cloud-bigquery/noxfile.py @@ -15,13 +15,13 @@ from __future__ import absolute_import import contextlib -from functools import wraps import os import pathlib -from typing import Generator import re import shutil import time +from functools import wraps +from typing import Generator import nox diff --git a/packages/google-cloud-bigquery/tests/unit/test_client.py b/packages/google-cloud-bigquery/tests/unit/test_client.py index 0c939f27f3fe..494894466209 100644 --- a/packages/google-cloud-bigquery/tests/unit/test_client.py +++ b/packages/google-cloud-bigquery/tests/unit/test_client.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy import collections +import copy import datetime import decimal import gzip @@ -24,14 +24,13 @@ import operator import os import unittest -from unittest import mock import warnings +from unittest import mock import packaging import pytest import requests - try: import opentelemetry except ImportError: @@ -50,19 +49,17 @@ raise ImportError(msg) from exc import google.api_core.exceptions -from google.api_core import client_info import google.cloud._helpers -from google.cloud import bigquery - -from google.cloud.bigquery.dataset import DatasetReference, Dataset -from google.cloud.bigquery.enums import UpdateMode, DatasetView, TimestampPrecision -from google.cloud.bigquery import exceptions -from google.cloud.bigquery import ParquetOptions import google.cloud.bigquery.retry -from google.cloud.bigquery.retry import DEFAULT_TIMEOUT import google.cloud.bigquery.table - +from google.api_core import client_info +from google.cloud import bigquery +from google.cloud.bigquery import ParquetOptions, exceptions +from google.cloud.bigquery.dataset import Dataset, DatasetReference +from google.cloud.bigquery.enums import DatasetView, TimestampPrecision, UpdateMode +from google.cloud.bigquery.retry import DEFAULT_TIMEOUT from test_utils.imports import maybe_fail_import + from tests.unit.helpers import make_connection @@ -234,8 +231,8 @@ def test_ctor_w_location(self): self.assertEqual(client.location, location) def test_ctor_w_query_job_config(self): - from google.cloud.bigquery._http import Connection from google.cloud.bigquery import QueryJobConfig + from google.cloud.bigquery._http import Connection creds = _make_credentials() http = object() @@ -259,8 +256,8 @@ def test_ctor_w_query_job_config(self): self.assertTrue(client._default_query_job_config.dry_run) def test_ctor_w_load_job_config(self): - from google.cloud.bigquery._http import Connection from google.cloud.bigquery import LoadJobConfig + from google.cloud.bigquery._http import Connection creds = _make_credentials() http = object() @@ -309,6 +306,7 @@ def test__call_api_extra_headers(self): def test__call_api_span_creator_not_called(self): from concurrent.futures import TimeoutError + from google.cloud.bigquery.retry import DEFAULT_RETRY creds = _make_credentials() @@ -333,6 +331,7 @@ def test__call_api_span_creator_not_called(self): def test__call_api_span_creator_called(self): from concurrent.futures import TimeoutError + from google.cloud.bigquery.retry import DEFAULT_RETRY creds = _make_credentials() @@ -482,8 +481,8 @@ def test__get_query_results_hit(self): self.assertTrue(query_results.complete) def test__list_rows_from_query_results_w_none_timeout(self): - from google.cloud.exceptions import NotFound from google.cloud.bigquery.schema import SchemaField + from google.cloud.exceptions import NotFound creds = _make_credentials() client = self._make_one(self.PROJECT, creds) @@ -517,8 +516,8 @@ def test__list_rows_from_query_results_w_none_timeout(self): def test__list_rows_from_query_results_w_default_timeout(self): import google.cloud.bigquery.client - from google.cloud.exceptions import NotFound from google.cloud.bigquery.schema import SchemaField + from google.cloud.exceptions import NotFound creds = _make_credentials() client = self._make_one(self.PROJECT, creds) @@ -814,6 +813,7 @@ def test_get_dataset_with_invalid_dataset_view(self): def test_ensure_bqstorage_client_creating_new_instance(self): bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") + import google.api_core.gapic_v1.client_info mock_client = mock.create_autospec(bigquery_storage.BigQueryReadClient) mock_client_instance = object() @@ -821,21 +821,113 @@ def test_ensure_bqstorage_client_creating_new_instance(self): creds = _make_credentials() client = self._make_one(project=self.PROJECT, credentials=creds) + client_info = google.api_core.gapic_v1.client_info.ClientInfo( + user_agent="test-agent" + ) + with mock.patch( "google.cloud.bigquery_storage.BigQueryReadClient", mock_client ): bqstorage_client = client._ensure_bqstorage_client( client_options=mock.sentinel.client_options, - client_info=mock.sentinel.client_info, + client_info=client_info, ) self.assertIs(bqstorage_client, mock_client_instance) - mock_client.assert_called_once_with( - credentials=creds, - client_options=mock.sentinel.client_options, - client_info=mock.sentinel.client_info, + mock_client.assert_called_once() + _, kwargs = mock_client.call_args + self.assertIs(kwargs["credentials"], creds) + self.assertIs(kwargs["client_options"], mock.sentinel.client_options) + self.assertIn("test-agent", kwargs["client_info"].user_agent) + self.assertIn("pandas-gbq", kwargs["client_info"].user_agent) + + def test_ensure_bqstorage_client_pandas_gbq_installed(self): + bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") + import sys + + import google.api_core.gapic_v1.client_info + + mock_client = mock.create_autospec(bigquery_storage.BigQueryReadClient) + creds = _make_credentials() + client = self._make_one(project=self.PROJECT, credentials=creds) + client_info = google.api_core.gapic_v1.client_info.ClientInfo( + user_agent="app-agent" + ) + + mock_pandas = mock.Mock() + mock_pandas.__version__ = "0.13.0" + + with mock.patch( + "google.cloud.bigquery_storage.BigQueryReadClient", mock_client + ), mock.patch.dict(sys.modules, {"pandas_gbq": mock_pandas}): + client._ensure_bqstorage_client(client_info=client_info) + + mock_client.assert_called_once() + _, kwargs = mock_client.call_args + self.assertEqual( + kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.13.0" + ) + + def test_ensure_bqstorage_client_pandas_gbq_not_installed(self): + bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") + import sys + + import google.api_core.gapic_v1.client_info + + mock_client = mock.create_autospec(bigquery_storage.BigQueryReadClient) + creds = _make_credentials() + client = self._make_one(project=self.PROJECT, credentials=creds) + client_info = google.api_core.gapic_v1.client_info.ClientInfo( + user_agent="app-agent" ) + with mock.patch( + "google.cloud.bigquery_storage.BigQueryReadClient", mock_client + ), mock.patch.dict(sys.modules, {"pandas_gbq": None}): + client._ensure_bqstorage_client(client_info=client_info) + + mock_client.assert_called_once() + _, kwargs = mock_client.call_args + self.assertEqual(kwargs["client_info"].user_agent, "app-agent pandas-gbq/0.0.0") + + def test_ensure_bqstorage_client_client_info_none(self): + bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") + import sys + + mock_client = mock.create_autospec(bigquery_storage.BigQueryReadClient) + creds = _make_credentials() + client = self._make_one(project=self.PROJECT, credentials=creds) + + with mock.patch( + "google.cloud.bigquery_storage.BigQueryReadClient", mock_client + ), mock.patch.dict(sys.modules, {"pandas_gbq": None}): + client._ensure_bqstorage_client(client_info=None) + + mock_client.assert_called_once() + _, kwargs = mock_client.call_args + self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0") + + def test_ensure_bqstorage_client_client_info_user_agent_none(self): + bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage") + import sys + + import google.api_core.gapic_v1.client_info + + mock_client = mock.create_autospec(bigquery_storage.BigQueryReadClient) + creds = _make_credentials() + client = self._make_one(project=self.PROJECT, credentials=creds) + + client_info = google.api_core.gapic_v1.client_info.ClientInfo(user_agent=None) + + with mock.patch( + "google.cloud.bigquery_storage.BigQueryReadClient", mock_client + ), mock.patch.dict(sys.modules, {"pandas_gbq": None}): + client._ensure_bqstorage_client(client_info=client_info) + + mock_client.assert_called_once() + _, kwargs = mock_client.call_args + self.assertEqual(kwargs["client_info"].user_agent, "pandas-gbq/0.0.0") + def test_ensure_bqstorage_client_missing_dependency(self): creds = _make_credentials() client = self._make_one(project=self.PROJECT, credentials=creds) @@ -925,8 +1017,7 @@ def test_ensure_bqstorage_client_existing_client_check_fails(self): assert matching_warnings, "Obsolete dependency warning not raised." def test_create_routine_w_minimal_resource(self): - from google.cloud.bigquery.routine import Routine - from google.cloud.bigquery.routine import RoutineReference + from google.cloud.bigquery.routine import Routine, RoutineReference creds = _make_credentials() path = "/projects/test-routine-project/datasets/test_routines/routines" @@ -1082,8 +1173,7 @@ def test_create_routine_w_conflict_exists_ok(self): ) def test_create_table_w_day_partition(self): - from google.cloud.bigquery.table import Table - from google.cloud.bigquery.table import TimePartitioning + from google.cloud.bigquery.table import Table, TimePartitioning path = "projects/%s/datasets/%s/tables" % (self.PROJECT, self.DS_ID) creds = _make_credentials() @@ -1198,8 +1288,7 @@ def test_create_table_w_encryption_configuration(self): self.assertEqual(got.table_id, self.TABLE_ID) def test_create_table_w_day_partition_and_expire(self): - from google.cloud.bigquery.table import Table - from google.cloud.bigquery.table import TimePartitioning + from google.cloud.bigquery.table import Table, TimePartitioning path = "projects/%s/datasets/%s/tables" % (self.PROJECT, self.DS_ID) creds = _make_credentials() @@ -1610,8 +1699,7 @@ def test_get_model_w_string(self): self.assertEqual(got.model_id, self.MODEL_ID) def test_get_routine(self): - from google.cloud.bigquery.routine import Routine - from google.cloud.bigquery.routine import RoutineReference + from google.cloud.bigquery.routine import Routine, RoutineReference full_routine_id = "test-routine-project.test_routines.minimal_routine" routines = [ @@ -1721,10 +1809,12 @@ def test_get_table_sets_user_agent(self): self.assertIn("my-application/1.2.3", expected_user_agent) def test_get_iam_policy(self): - from google.cloud.bigquery.iam import BIGQUERY_DATA_OWNER_ROLE - from google.cloud.bigquery.iam import BIGQUERY_DATA_EDITOR_ROLE - from google.cloud.bigquery.iam import BIGQUERY_DATA_VIEWER_ROLE from google.api_core.iam import Policy + from google.cloud.bigquery.iam import ( + BIGQUERY_DATA_EDITOR_ROLE, + BIGQUERY_DATA_OWNER_ROLE, + BIGQUERY_DATA_VIEWER_ROLE, + ) PATH = "/projects/{}/datasets/{}/tables/{}:getIamPolicy".format( self.PROJECT, @@ -1797,10 +1887,12 @@ def test_get_iam_policy_w_invalid_version(self): client.get_iam_policy(self.TABLE_REF, requested_policy_version=2) def test_set_iam_policy(self): - from google.cloud.bigquery.iam import BIGQUERY_DATA_OWNER_ROLE - from google.cloud.bigquery.iam import BIGQUERY_DATA_EDITOR_ROLE - from google.cloud.bigquery.iam import BIGQUERY_DATA_VIEWER_ROLE from google.api_core.iam import Policy + from google.cloud.bigquery.iam import ( + BIGQUERY_DATA_EDITOR_ROLE, + BIGQUERY_DATA_OWNER_ROLE, + BIGQUERY_DATA_VIEWER_ROLE, + ) PATH = "/projects/%s/datasets/%s/tables/%s:setIamPolicy" % ( self.PROJECT, @@ -1851,10 +1943,12 @@ def test_set_iam_policy(self): self.assertEqual(dict(returned_policy), dict(policy)) def test_set_iam_policy_updateMask(self): - from google.cloud.bigquery.iam import BIGQUERY_DATA_OWNER_ROLE - from google.cloud.bigquery.iam import BIGQUERY_DATA_EDITOR_ROLE - from google.cloud.bigquery.iam import BIGQUERY_DATA_VIEWER_ROLE from google.api_core.iam import Policy + from google.cloud.bigquery.iam import ( + BIGQUERY_DATA_EDITOR_ROLE, + BIGQUERY_DATA_OWNER_ROLE, + BIGQUERY_DATA_VIEWER_ROLE, + ) PATH = "/projects/%s/datasets/%s/tables/%s:setIamPolicy" % ( self.PROJECT, @@ -2029,7 +2123,7 @@ def test_update_dataset_w_invalid_field(self): ) def test_update_dataset(self): - from google.cloud.bigquery.dataset import Dataset, AccessEntry + from google.cloud.bigquery.dataset import AccessEntry, Dataset PATH = "projects/%s/datasets/%s" % (self.PROJECT, self.DS_ID) DESCRIPTION = "DESCRIPTION" @@ -2301,8 +2395,7 @@ def test_update_model(self): self.assertEqual(req[1]["headers"]["If-Match"], "etag") def test_update_routine(self): - from google.cloud.bigquery.routine import Routine - from google.cloud.bigquery.routine import RoutineArgument + from google.cloud.bigquery.routine import Routine, RoutineArgument full_routine_id = "routines-project.test_routines.updated_routine" resource = { @@ -2385,8 +2478,7 @@ def test_update_routine(self): self.assertEqual(req[1]["headers"]["If-Match"], "im-an-etag") def test_update_table(self): - from google.cloud.bigquery.schema import SchemaField - from google.cloud.bigquery.schema import PolicyTagList + from google.cloud.bigquery.schema import PolicyTagList, SchemaField from google.cloud.bigquery.table import Table path = "projects/%s/datasets/%s/tables/%s" % ( @@ -2577,8 +2669,8 @@ def test_update_table_only_use_legacy_sql(self): def test_update_table_w_query(self): import datetime - from google.cloud._helpers import UTC - from google.cloud._helpers import _millis + + from google.cloud._helpers import UTC, _millis from google.cloud.bigquery.schema import SchemaField from google.cloud.bigquery.table import Table @@ -2918,8 +3010,7 @@ def test_delete_model_w_not_found_ok_true(self): ) def test_delete_routine(self): - from google.cloud.bigquery.routine import Routine - from google.cloud.bigquery.routine import RoutineReference + from google.cloud.bigquery.routine import Routine, RoutineReference full_routine_id = "test-routine-project.test_routines.minimal_routine" routines = [ @@ -3201,8 +3292,8 @@ def test_create_job_query_config(self): self._create_job_helper(configuration) def test_create_job_query_config_w_rateLimitExceeded_error(self): - from google.cloud.exceptions import Forbidden from google.cloud.bigquery.retry import DEFAULT_RETRY + from google.cloud.exceptions import Forbidden query = "select count(*) from persons" configuration = { @@ -3283,8 +3374,8 @@ def test_job_from_resource_unknown_type(self): self.assertEqual(got.project, self.PROJECT) def test_get_job_miss_w_explict_project(self): - from google.cloud.exceptions import NotFound from google.cloud.bigquery.retry import DEFAULT_GET_JOB_TIMEOUT + from google.cloud.exceptions import NotFound OTHER_PROJECT = "OTHER_PROJECT" JOB_ID = "NONESUCH" @@ -3303,8 +3394,8 @@ def test_get_job_miss_w_explict_project(self): ) def test_get_job_miss_w_client_location(self): - from google.cloud.exceptions import NotFound from google.cloud.bigquery.retry import DEFAULT_GET_JOB_TIMEOUT + from google.cloud.exceptions import NotFound JOB_ID = "NONESUCH" creds = _make_credentials() @@ -3322,9 +3413,11 @@ def test_get_job_miss_w_client_location(self): ) def test_get_job_hit_w_timeout(self): - from google.cloud.bigquery.job import CreateDisposition - from google.cloud.bigquery.job import QueryJob - from google.cloud.bigquery.job import WriteDisposition + from google.cloud.bigquery.job import ( + CreateDisposition, + QueryJob, + WriteDisposition, + ) JOB_ID = "query_job" QUERY_DESTINATION_TABLE = "query_destination_table" @@ -4237,9 +4330,11 @@ def test_extract_table_w_client_location(self): ) def test_extract_table_generated_job_id(self): - from google.cloud.bigquery.job import ExtractJob - from google.cloud.bigquery.job import ExtractJobConfig - from google.cloud.bigquery.job import DestinationFormat + from google.cloud.bigquery.job import ( + DestinationFormat, + ExtractJob, + ExtractJobConfig, + ) JOB = "job_id" SOURCE = "source_table" @@ -4740,7 +4835,7 @@ def test_query_w_explicit_job_config(self): creds = _make_credentials() http = object() - from google.cloud.bigquery import QueryJobConfig, DatasetReference + from google.cloud.bigquery import DatasetReference, QueryJobConfig default_job_config = QueryJobConfig() default_job_config.default_dataset = DatasetReference( @@ -4860,7 +4955,7 @@ def test_query_preserving_explicit_default_job_config(self): creds = _make_credentials() http = object() - from google.cloud.bigquery import QueryJobConfig, DatasetReference + from google.cloud.bigquery import DatasetReference, QueryJobConfig default_job_config = QueryJobConfig() default_job_config.default_dataset = DatasetReference( @@ -4897,8 +4992,7 @@ def test_query_preserving_explicit_default_job_config(self): assert default_job_config.to_api_repr() == default_config_copy.to_api_repr() def test_query_w_invalid_job_config(self): - from google.cloud.bigquery import QueryJobConfig, DatasetReference - from google.cloud.bigquery import job + from google.cloud.bigquery import DatasetReference, QueryJobConfig, job job_id = "some-job-id" query = "select count(*) from persons" @@ -4952,7 +5046,7 @@ def test_query_w_explicit_job_config_override(self): creds = _make_credentials() http = object() - from google.cloud.bigquery import QueryJobConfig, DatasetReference + from google.cloud.bigquery import DatasetReference, QueryJobConfig default_job_config = QueryJobConfig() default_job_config.default_dataset = DatasetReference( @@ -5103,8 +5197,7 @@ def test_query_detect_location(self): self.assertIsNone(sent["jobReference"].get("location")) def test_query_w_udf_resources(self): - from google.cloud.bigquery.job import QueryJob - from google.cloud.bigquery.job import QueryJobConfig + from google.cloud.bigquery.job import QueryJob, QueryJobConfig from google.cloud.bigquery.query import UDFResource RESOURCE_URI = "gs://some-bucket/js/lib.js" @@ -5155,8 +5248,7 @@ def test_query_w_udf_resources(self): ) def test_query_w_query_parameters(self): - from google.cloud.bigquery.job import QueryJob - from google.cloud.bigquery.job import QueryJobConfig + from google.cloud.bigquery.job import QueryJob, QueryJobConfig from google.cloud.bigquery.query import ScalarQueryParameter JOB = "job_name" @@ -5297,8 +5389,7 @@ def test_query_job_rpc_fail_w_conflict_job_id_given(self): client.query("SELECT 1;", job_id="123", job_retry=None) def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails(self): - from google.api_core.exceptions import Conflict - from google.api_core.exceptions import DataLoss + from google.api_core.exceptions import Conflict, DataLoss from google.cloud.bigquery.job import QueryJob creds = _make_credentials() @@ -5321,8 +5412,7 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails(self): client.query("SELECT 1;", job_id=None) def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails_no_retries(self): - from google.api_core.exceptions import Conflict - from google.api_core.exceptions import DataLoss + from google.api_core.exceptions import Conflict, DataLoss from google.cloud.bigquery.job import QueryJob creds = _make_credentials() @@ -5693,9 +5783,8 @@ def test_insert_rows_wo_schema(self): def test_insert_rows_w_schema(self): import datetime - from google.cloud._helpers import UTC - from google.cloud._helpers import _datetime_to_rfc3339 - from google.cloud._helpers import _RFC3339_MICROS + + from google.cloud._helpers import _RFC3339_MICROS, UTC, _datetime_to_rfc3339 from google.cloud.bigquery.schema import SchemaField WHEN_TS = 1437767599.006 @@ -5753,9 +5842,8 @@ def _row_data(row): def test_insert_rows_w_list_of_dictionaries(self): import datetime - from google.cloud._helpers import UTC - from google.cloud._helpers import _datetime_to_rfc3339 - from google.cloud._helpers import _RFC3339_MICROS + + from google.cloud._helpers import _RFC3339_MICROS, UTC, _datetime_to_rfc3339 from google.cloud.bigquery.schema import SchemaField from google.cloud.bigquery.table import Table @@ -5822,8 +5910,7 @@ def _row_data(row): def test_insert_rows_w_list_of_Rows(self): from google.cloud.bigquery.schema import SchemaField - from google.cloud.bigquery.table import Table - from google.cloud.bigquery.table import Row + from google.cloud.bigquery.table import Row, Table PATH = "projects/%s/datasets/%s/tables/%s/insertAll" % ( self.PROJECT, @@ -6797,10 +6884,10 @@ def test_list_partitions_with_string_id(self): def test_list_rows(self): import datetime + from google.cloud._helpers import UTC from google.cloud.bigquery.schema import SchemaField - from google.cloud.bigquery.table import Table - from google.cloud.bigquery.table import Row + from google.cloud.bigquery.table import Row, Table PATH = "projects/%s/datasets/%s/tables/%s/data" % ( self.PROJECT, @@ -6902,8 +6989,7 @@ def test_list_rows_pico_timestamp(self): def test_list_rows_w_start_index_w_page_size(self): from google.cloud.bigquery.schema import SchemaField - from google.cloud.bigquery.table import Table - from google.cloud.bigquery.table import Row + from google.cloud.bigquery.table import Row, Table PATH = "projects/%s/datasets/%s/tables/%s/data" % ( self.PROJECT, @@ -7312,8 +7398,7 @@ class TestClientUpload(object): @classmethod def _make_client(cls, transport=None, location=None): - from google.cloud.bigquery import _http - from google.cloud.bigquery import client + from google.cloud.bigquery import _http, client cl = client.Client( project=cls.PROJECT, @@ -7375,8 +7460,7 @@ def _make_gzip_file_obj(self, writable): @staticmethod def _make_config(): - from google.cloud.bigquery.job import LoadJobConfig - from google.cloud.bigquery.job import SourceFormat + from google.cloud.bigquery.job import LoadJobConfig, SourceFormat config = LoadJobConfig() config.source_format = SourceFormat.CSV @@ -7480,8 +7564,7 @@ def test_load_table_from_file_w_client_location(self): def test_load_table_from_file_resumable_metadata(self): from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES - from google.cloud.bigquery.job import CreateDisposition - from google.cloud.bigquery.job import WriteDisposition + from google.cloud.bigquery.job import CreateDisposition, WriteDisposition client = self._make_client() file_obj = self._make_file_obj() @@ -7644,8 +7727,8 @@ def test_load_table_from_file_with_writable_gzip(self): ) def test_load_table_from_file_failure(self): - from google.resumable_media import InvalidResponse from google.cloud import exceptions + from google.resumable_media import InvalidResponse client = self._make_client() file_obj = self._make_file_obj() @@ -7800,8 +7883,8 @@ def test_load_table_from_file_w_default_load_config(self): def test_load_table_from_dataframe(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import PolicyTagList, SchemaField client = self._make_client() @@ -7896,8 +7979,8 @@ def test_load_table_from_dataframe(self): def test_load_table_from_dataframe_w_client_location(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client(location=self.LOCATION) @@ -7941,8 +8024,8 @@ def test_load_table_from_dataframe_w_client_location(self): def test_load_table_from_dataframe_w_custom_job_config_wihtout_source_format(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -7996,8 +8079,8 @@ def test_load_table_from_dataframe_w_custom_job_config_wihtout_source_format(sel def test_load_table_from_dataframe_w_custom_job_config_w_source_format(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8052,8 +8135,8 @@ def test_load_table_from_dataframe_w_custom_job_config_w_source_format(self): def test_load_table_from_dataframe_w_parquet_options_none(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8104,8 +8187,8 @@ def test_load_table_from_dataframe_w_parquet_options_none(self): def test_load_table_from_dataframe_w_list_inference_none(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8164,8 +8247,8 @@ def test_load_table_from_dataframe_w_list_inference_none(self): def test_load_table_from_dataframe_w_explicit_job_config_override(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8225,8 +8308,8 @@ def test_load_table_from_dataframe_w_explicit_job_config_override(self): def test_load_table_from_dataframe_w_default_load_config(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8275,8 +8358,8 @@ def test_load_table_from_dataframe_w_default_load_config(self): def test_load_table_from_dataframe_w_list_inference_false(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8356,8 +8439,8 @@ def test_load_table_from_dataframe_w_custom_job_config_w_wrong_source_format(sel def test_load_table_from_dataframe_w_automatic_schema(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8457,8 +8540,8 @@ def test_load_table_from_dataframe_w_automatic_schema(self): def test_load_table_from_dataframe_w_automatic_schema_detection_fails(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES client = self._make_client() @@ -8521,8 +8604,8 @@ def test_load_table_from_dataframe_w_automatic_schema_detection_fails(self): def test_load_table_from_dataframe_w_index_and_auto_schema(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8619,8 +8702,8 @@ def test_load_table_from_dataframe_unknown_table(self): def test_load_table_from_dataframe_w_nullable_int64_datatype(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8663,8 +8746,8 @@ def test_load_table_from_dataframe_w_nullable_int64_datatype(self): def test_load_table_from_dataframe_w_nullable_int64_datatype_automatic_schema(self): pandas = pytest.importorskip("pandas") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8711,8 +8794,8 @@ def test_load_table_from_dataframe_w_nullable_int64_datatype_automatic_schema(se def test_load_table_from_dataframe_struct_fields(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8775,8 +8858,8 @@ def test_load_table_from_dataframe_array_fields(self): """ pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8840,8 +8923,8 @@ def test_load_table_from_dataframe_array_fields_w_auto_schema(self): """ pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -8910,8 +8993,8 @@ def test_load_table_from_dataframe_array_fields_w_auto_schema(self): def test_load_table_from_dataframe_w_partial_schema(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -9126,9 +9209,9 @@ def test_load_table_from_dataframe_w_nulls(self): """ pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.schema import SchemaField - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES + from google.cloud.bigquery.schema import SchemaField client = self._make_client() records = [{"name": None, "age": None}, {"name": None, "age": None}] @@ -9183,8 +9266,8 @@ def test_load_table_from_dataframe_w_invaild_job_config(self): def test_load_table_from_dataframe_with_csv_source_format(self): pandas = pytest.importorskip("pandas") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField client = self._make_client() @@ -9234,10 +9317,11 @@ def test_load_table_from_dataframe_with_csv_source_format(self): def test_load_table_from_dataframe_w_higher_scale_decimal128_datatype(self): pandas = pytest.importorskip("pandas") pytest.importorskip("pyarrow") - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES + from decimal import Decimal + from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.schema import SchemaField - from decimal import Decimal client = self._make_client() dataframe = pandas.DataFrame({"x": [Decimal("0.1234567891")]}) @@ -9277,8 +9361,8 @@ def test_load_table_from_dataframe_w_higher_scale_decimal128_datatype(self): # With autodetect specified, we pass the value as is. For more info, see # https://github.com/googleapis/python-bigquery/issues/1228#issuecomment-1910946297 def test_load_table_from_json_basic_use(self): - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES client = self._make_client() @@ -9415,8 +9499,8 @@ def test_load_table_from_json_w_invalid_job_config(self): # client sets autodetect == False # For more details, see https://github.com/googleapis/python-bigquery/issues/1228#issuecomment-1910946297 def test_load_table_from_json_wo_schema_wo_autodetect_write_append_w_table(self): - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.job import WriteDisposition client = self._make_client() @@ -9477,8 +9561,8 @@ def test_load_table_from_json_wo_schema_wo_autodetect_write_append_w_table(self) # For more details, see https://github.com/googleapis/python-bigquery/issues/1228#issuecomment-1910946297 def test_load_table_from_json_wo_schema_wo_autodetect_write_append_wo_table(self): import google.api_core.exceptions as core_exceptions - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.job import WriteDisposition client = self._make_client() @@ -9532,8 +9616,8 @@ def test_load_table_from_json_wo_schema_wo_autodetect_write_append_wo_table(self # client sets autodetect == True # For more details, see https://github.com/googleapis/python-bigquery/issues/1228#issuecomment-1910946297 def test_load_table_from_json_wo_schema_wo_autodetect_others(self): - from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery import job + from google.cloud.bigquery.client import _DEFAULT_NUM_RETRIES from google.cloud.bigquery.job import WriteDisposition client = self._make_client() From 264008d2658eaa522a2bb370dc0aba9407ac21c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Mon, 29 Jun 2026 21:36:38 +0000 Subject: [PATCH 3/7] Update packages/google-cloud-bigquery/google/cloud/bigquery/client.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/google-cloud-bigquery/google/cloud/bigquery/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py index 983d4560e67b..76571f8c18a7 100644 --- a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py +++ b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py @@ -628,7 +628,7 @@ def _ensure_bqstorage_client( try: import pandas_gbq except ImportError: - pandas_gbq = None + pandas_gbq = None # type: ignore[assignment] if pandas_gbq is None: user_agent = "pandas-gbq/0.0.0" From e9cc092111a837c34479dfdbbb575bcf6a31e5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Mon, 29 Jun 2026 22:03:06 +0000 Subject: [PATCH 4/7] fix test and mypy --- .../google-cloud-bigquery/google/cloud/bigquery/client.py | 4 ++-- packages/google-cloud-bigquery/tests/unit/test_magics.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py index 76571f8c18a7..d765b6e2ca2d 100644 --- a/packages/google-cloud-bigquery/google/cloud/bigquery/client.py +++ b/packages/google-cloud-bigquery/google/cloud/bigquery/client.py @@ -626,9 +626,9 @@ def _ensure_bqstorage_client( import google.api_core.gapic_v1.client_info try: - import pandas_gbq + import pandas_gbq # type: ignore except ImportError: - pandas_gbq = None # type: ignore[assignment] + pandas_gbq = None # type: ignore if pandas_gbq is None: user_agent = "pandas-gbq/0.0.0" diff --git a/packages/google-cloud-bigquery/tests/unit/test_magics.py b/packages/google-cloud-bigquery/tests/unit/test_magics.py index 74b8265b3c56..03a3a2dbbdba 100644 --- a/packages/google-cloud-bigquery/tests/unit/test_magics.py +++ b/packages/google-cloud-bigquery/tests/unit/test_magics.py @@ -694,7 +694,8 @@ def warning_match(warning): assert kwargs.get("credentials") is mock_credentials client_info = kwargs.get("client_info") assert client_info is not None - assert client_info.user_agent == "ipython-" + IPython.__version__ + assert client_info.user_agent.startswith("ipython-" + IPython.__version__) + assert "pandas-gbq" in client_info.user_agent query_job_mock.to_dataframe.assert_called_once_with( bqstorage_client=bqstorage_instance_mock, From 8e2737890506e3db100d0662cc2c128cc6271734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Tue, 30 Jun 2026 20:56:01 +0000 Subject: [PATCH 5/7] update google-api-core --- packages/google-cloud-bigquery/pyproject.toml | 2 +- packages/google-cloud-bigquery/testing/constraints-3.10.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-bigquery/pyproject.toml b/packages/google-cloud-bigquery/pyproject.toml index 406872e9d1f4..836472022963 100644 --- a/packages/google-cloud-bigquery/pyproject.toml +++ b/packages/google-cloud-bigquery/pyproject.toml @@ -41,7 +41,7 @@ classifiers = [ "Topic :: Internet", ] dependencies = [ - "google-api-core[grpc] >= 2.11.1, < 3.0.0", + "google-api-core[grpc] >= 2.25.0, < 3.0.0", "google-auth[pyopenssl] >= 2.14.1, < 3.0.0", "google-cloud-core >= 2.4.1, < 3.0.0", "google-resumable-media >= 2.0.0, < 3.0.0", diff --git a/packages/google-cloud-bigquery/testing/constraints-3.10.txt b/packages/google-cloud-bigquery/testing/constraints-3.10.txt index 276999e72d4d..8e63363f1096 100644 --- a/packages/google-cloud-bigquery/testing/constraints-3.10.txt +++ b/packages/google-cloud-bigquery/testing/constraints-3.10.txt @@ -1,4 +1,4 @@ -google-api-core==2.11.1 +google-api-core==2.25.0 google-auth==2.14.1 google-cloud-core==2.4.1 google-resumable-media==2.0.0 From 8001c7ad44fa041f4681a70e047aa23a906df297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Tue, 30 Jun 2026 21:49:04 +0000 Subject: [PATCH 6/7] ignore unused import skip --- .../google-cloud-bigquery/tests/unit/test_legacy_types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py b/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py index 75f3e77d785f..f3b0c650418f 100644 --- a/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py +++ b/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py @@ -13,11 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest - import warnings -try: +import pytest + +try: # pragma: NO COVER import proto except ImportError: proto = None # type: ignore From 5649e6e606bafa25fc23d53d587e7c4ba4a47041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Wed, 1 Jul 2026 01:27:13 +0000 Subject: [PATCH 7/7] Update packages/google-cloud-bigquery/tests/unit/test_legacy_types.py --- .../google-cloud-bigquery/tests/unit/test_legacy_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py b/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py index f3b0c650418f..4dd6e20ef558 100644 --- a/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py +++ b/packages/google-cloud-bigquery/tests/unit/test_legacy_types.py @@ -17,9 +17,9 @@ import pytest -try: # pragma: NO COVER +try: import proto -except ImportError: +except ImportError: # pragma: NO COVER proto = None # type: ignore