Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
rinarakaki committed Oct 11, 2024
1 parent e5fb3ea commit a749bd3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion google/cloud/_helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 19 additions & 4 deletions google/cloud/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.pyright]
typeCheckingMode = "strict"

0 comments on commit a749bd3

Please sign in to comment.