Skip to content

Commit 0af9073

Browse files
committed
refactor: harden version checks and user-agent creation based on PR feedback
1 parent 7646f22 commit 0af9073

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/google-cloud-bigquery/google/cloud/bigquery/_versions_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def installed_version(self) -> packaging.version.Version:
264264
self._installed_version = packaging.version.parse(
265265
getattr(pandas_gbq, "__version__", "0.0.0")
266266
)
267-
except ImportError:
267+
except Exception:
268268
self._installed_version = packaging.version.parse("0.0.0")
269269

270270
return self._installed_version
@@ -279,7 +279,7 @@ def delegation_api_version(self) -> int:
279279
self._delegation_api_version = getattr(
280280
pandas_gbq, "_internal_delegation_api_version", 0
281281
)
282-
except ImportError:
282+
except Exception:
283283
self._delegation_api_version = 0
284284

285285
return self._delegation_api_version

packages/google-cloud-bigquery/google/cloud/bigquery/table.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,8 @@ def to_dataframe(
28192819
if client_info:
28202820
ua = client_info.user_agent or ""
28212821
if "pandas-gbq" not in ua:
2822-
client_info.user_agent = f"{ua} pandas-gbq/{pandas_gbq.__version__}".strip()
2822+
pandas_gbq_version = getattr(pandas_gbq, "__version__", "0.0.0")
2823+
client_info.user_agent = f"{ua} pandas-gbq/{pandas_gbq_version}".strip()
28232824

28242825
return pandas_gbq.pandas.from_row_iterator(
28252826
self,

0 commit comments

Comments
 (0)