From a749bd38c022244eeb5af82bd6ad3d989f4245dc Mon Sep 17 00:00:00 2001 From: rinarakaki Date: Fri, 11 Oct 2024 06:44:50 +0000 Subject: [PATCH] Update --- google/cloud/_helpers/__init__.py | 2 +- google/cloud/client/__init__.py | 23 +++++++++++++++++++---- pyproject.toml | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml diff --git a/google/cloud/_helpers/__init__.py b/google/cloud/_helpers/__init__.py index 7a198cc..70e5685 100644 --- a/google/cloud/_helpers/__init__.py +++ b/google/cloud/_helpers/__init__.py @@ -136,7 +136,7 @@ def _ensure_tuple_or_list(arg_name, tuple_or_list): return list(tuple_or_list) -def _determine_default_project(project=None): +def _determine_default_project(project: Optional[str] = None): """Determine default project ID explicitly or implicitly as fall-back. See :func:`google.auth.default` for details on how the default project diff --git a/google/cloud/client/__init__.py b/google/cloud/client/__init__.py index 93e5d22..2bb0a3a 100644 --- a/google/cloud/client/__init__.py +++ b/google/cloud/client/__init__.py @@ -18,14 +18,16 @@ import json import os from pickle import PicklingError -from typing import Tuple +from typing import Optional, Tuple from typing import Union import google.api_core.client_options +from google.api_core.client_options import ClientOptions import google.api_core.exceptions import google.auth from google.auth import environment_vars import google.auth.credentials +from google.auth.credentials import Credentials import google.auth.transport.requests from google.cloud._helpers import _determine_default_project from google.oauth2 import service_account @@ -150,7 +152,12 @@ class Client(_ClientFactoryMixin): Needs to be set by subclasses. """ - def __init__(self, credentials=None, _http=None, client_options=None): + def __init__( + self, + credentials: Optional[Credentials] = None, + _http=None, + client_options: Optional[ClientOptions] = None, + ): if isinstance(client_options, dict): client_options = google.api_core.client_options.from_dict(client_options) if client_options is None: @@ -248,7 +255,9 @@ class _ClientProjectMixin(object): if the project value is invalid. """ - def __init__(self, project=None, credentials=None): + def __init__( + self, project: Optional[str] = None, credentials: Optional[Credentials] = None + ): # This test duplicates the one from `google.auth.default`, but earlier, # for backward compatibility: we want the environment variable to # override any project set on the credentials. See: @@ -316,7 +325,13 @@ class ClientWithProject(Client, _ClientProjectMixin): _SET_PROJECT = True # Used by from_service_account_json() - def __init__(self, project=None, credentials=None, client_options=None, _http=None): + def __init__( + self, + project: Optional[str] = None, + credentials: Optional[Credentials] = None, + client_options: Optional[ClientOptions] = None, + _http=None, + ): _ClientProjectMixin.__init__(self, project=project, credentials=credentials) Client.__init__( self, credentials=credentials, client_options=client_options, _http=_http diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..745d3b9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.pyright] +typeCheckingMode = "strict"