From f7959e3521f78f542f163a2ec9b61ceb16644bf3 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 23 Jan 2026 20:14:46 +0000 Subject: [PATCH] fix: fix mypy errors --- .../automl_v1beta1/services/tables/gcs_client.py | 14 +++++++++----- packages/google-cloud-automl/noxfile.py | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/tables/gcs_client.py b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/tables/gcs_client.py index 99d40da2867c..aecb9d973922 100644 --- a/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/tables/gcs_client.py +++ b/packages/google-cloud-automl/google/cloud/automl_v1beta1/services/tables/gcs_client.py @@ -23,13 +23,17 @@ try: import pandas + _PANDAS_INSTALLED = True except ImportError: # pragma: NO COVER - pandas = None + _PANDAS_INSTALLED = False try: - from google.cloud import storage + # TODO(https://github.com/googleapis/python-storage/issues/318): + # Remove `type: ignore` once this bug is fixed + from google.cloud import storage # type: ignore + _STORAGE_INSTALLED = True except ImportError: # pragma: NO COVER - storage = None + _STORAGE_INSTALLED = False _LOGGER = logging.getLogger(__name__) _PANDAS_REQUIRED = "pandas is required to verify type DataFrame." @@ -59,7 +63,7 @@ def __init__(self, bucket_name=None, client=None, credentials=None, project=None the client will attempt to ascertain the credentials from the environment. """ - if storage is None: + if not _STORAGE_INSTALLED: raise ImportError(_STORAGE_REQUIRED) if client is not None: @@ -119,7 +123,7 @@ def upload_pandas_dataframe(self, dataframe, uploaded_csv_name=None): Returns: A string representing the GCS URI of the uploaded CSV. """ - if pandas is None: + if not _PANDAS_INSTALLED: raise ImportError(_PANDAS_REQUIRED) if not isinstance(dataframe, pandas.DataFrame): diff --git a/packages/google-cloud-automl/noxfile.py b/packages/google-cloud-automl/noxfile.py index bcafe0750c9a..4a482fbfa495 100644 --- a/packages/google-cloud-automl/noxfile.py +++ b/packages/google-cloud-automl/noxfile.py @@ -101,6 +101,7 @@ def mypy(session): "mypy<1.16.0", "types-requests", "types-protobuf", + "pandas-stubs", ) session.install(".") session.run(