Skip to content

Commit

Permalink
fix: Fix scanning google cloud with service account credentials file (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion authored Nov 14, 2024
1 parent 85b8de2 commit 97c82d0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 25 additions & 3 deletions py-polars/polars/io/cloud/credential_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions py-polars/polars/meta/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 97c82d0

Please sign in to comment.