From 97c82d0e45488681a784e0742574c903b4fc2b9d Mon Sep 17 00:00:00 2001 From: nameexhaustion Date: Fri, 15 Nov 2024 00:07:06 +1100 Subject: [PATCH] fix: Fix scanning google cloud with service account credentials file (#19782) --- .../polars/io/cloud/credential_provider.py | 28 +++++++++++++++++-- py-polars/polars/meta/versions.py | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/py-polars/polars/io/cloud/credential_provider.py b/py-polars/polars/io/cloud/credential_provider.py index 26e8ebf6826e..69f2bdbdf67a 100644 --- a/py-polars/polars/io/cloud/credential_provider.py +++ b/py-polars/polars/io/cloud/credential_provider.py @@ -150,8 +150,21 @@ class CredentialProviderGCP(CredentialProvider): at any point without it being considered a breaking change. """ - def __init__(self) -> None: - """Initialize a credential provider for Google Cloud (GCP).""" + def __init__( + self, + *, + scopes: Any | None = None, + request: Any | None = None, + quota_project_id: Any | None = None, + default_scopes: Any | None = None, + ) -> None: + """ + Initialize a credential provider for Google Cloud (GCP). + + Parameters + ---------- + Parameters are passed to `google.auth.default()` + """ msg = "`CredentialProviderAWS` functionality is considered unstable" issue_unstable_warning(msg) @@ -168,7 +181,16 @@ def __init__(self) -> None: # # So we just bypass it with a __dict__[] (because ruff complains about # getattr) :| - creds, _ = google.auth.__dict__["default"]() + creds, _ = google.auth.__dict__["default"]( + scopes=( + scopes + if scopes is not None + else ["https://www.googleapis.com/auth/cloud-platform"] + ), + request=request, + quota_project_id=quota_project_id, + default_scopes=default_scopes, + ) self.creds = creds def __call__(self) -> CredentialProviderFunctionReturn: diff --git a/py-polars/polars/meta/versions.py b/py-polars/polars/meta/versions.py index 425f01d91a85..f9f631dac5fd 100644 --- a/py-polars/polars/meta/versions.py +++ b/py-polars/polars/meta/versions.py @@ -68,12 +68,14 @@ def _get_dependency_list() -> list[str]: return [ "adbc_driver_manager", "altair", + "boto3", "cloudpickle", "connectorx", "deltalake", "fastexcel", "fsspec", "gevent", + "google.auth", "great_tables", "matplotlib", "nest_asyncio",