From d210080914f0c5aa7dfc7dd3a6bd5181043150ad Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 3 Jan 2018 14:18:37 -0800 Subject: [PATCH 1/2] Document DefaultCredentialsError could be raised if credentials not supplied. Also, use Napoleon-style docs for the changed docs. --- bigquery/google/cloud/bigquery/client.py | 41 +++++++++++++----------- core/google/cloud/client.py | 31 ++++++++++-------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/bigquery/google/cloud/bigquery/client.py b/bigquery/google/cloud/bigquery/client.py index 54885c3e24ef..c6ad1f0a45e1 100644 --- a/bigquery/google/cloud/bigquery/client.py +++ b/bigquery/google/cloud/bigquery/client.py @@ -93,25 +93,28 @@ def from_api_repr(cls, resource): class Client(ClientWithProject): """Client to bundle configuration needed for API requests. - :type project: str - :param project: the project which the client acts on behalf of. Will be - passed when creating a dataset / job. If not passed, - falls back to the default inferred from the environment. - - :type credentials: :class:`~google.auth.credentials.Credentials` - :param credentials: (Optional) The OAuth2 Credentials to use for this - client. If not passed (and if no ``_http`` object is - passed), falls back to the default inferred from the - environment. - - :type _http: :class:`~requests.Session` - :param _http: (Optional) HTTP object to make requests. Can be any object - that defines ``request()`` with the same interface as - :meth:`requests.Session.request`. If not passed, an - ``_http`` object is created that is bound to the - ``credentials`` for the current object. - This parameter should be considered private, and could - change in the future. + Keyword Args: + project (str): + Project ID for the project which the client acts on behalf of. + Will be passed when creating a dataset / job. If not passed, + falls back to the default inferred from the environment. + credentials (google.auth.credentials.Credentials): + (Optional) The OAuth2 Credentials to use for this client. If not + passed (and if no ``_http`` object is passed), falls back to the + default inferred from the environment. + _http (requests.Session): + (Optional) HTTP object to make requests. Can be any object that + defines ``request()`` with the same interface as + :meth:`requests.Session.request`. If not passed, an ``_http`` + object is created that is bound to the ``credentials`` for the + current object. + This parameter should be considered private, and could change in + the future. + + Raises: + google.auth.exceptions.DefaultCredentialsError: + Raised if ``credentials`` is not specified and the library fails + to acquire default credentials. """ SCOPE = ('https://www.googleapis.com/auth/bigquery', diff --git a/core/google/cloud/client.py b/core/google/cloud/client.py index 900de368e5c2..92e868aa0365 100644 --- a/core/google/cloud/client.py +++ b/core/google/cloud/client.py @@ -94,20 +94,23 @@ class Client(_ClientFactoryMixin): Callers and subclasses may seek to use the private key from ``credentials`` to sign data. - :type credentials: :class:`~google.auth.credentials.Credentials` - :param credentials: (Optional) The OAuth2 Credentials to use for this - client. If not passed (and if no ``_http`` object is - passed), falls back to the default inferred from the - environment. - - :type _http: :class:`~requests.Session` - :param _http: (Optional) HTTP object to make requests. Can be any object - that defines ``request()`` with the same interface as - :meth:`requests.Session.request`. If not passed, an - ``_http`` object is created that is bound to the - ``credentials`` for the current object. - This parameter should be considered private, and could - change in the future. + Keyword Args: + credentials (google.auth.credentials.Credentials): + (Optional) The OAuth2 Credentials to use for this client. If not + passed (and if no ``_http`` object is passed), falls back to the + default inferred from the environment. + _http (requests.Session): + (Optional) HTTP object to make requests. Can be any object that + defines ``request()`` with the same interface as + :meth:`requests.Session.request`. If not passed, an ``_http`` + object is created that is bound to the ``credentials`` for the + current object. This parameter should be considered private, and + could change in the future. + + Raises: + google.auth.exceptions.DefaultCredentialsError: + Raised if ``credentials`` is not specified and the library fails + to acquire default credentials. """ SCOPE = None From c8d32a7a8c362b38daac924665003f899c41d033 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 3 Jan 2018 14:28:40 -0800 Subject: [PATCH 2/2] s/Keyword Args/Args --- bigquery/google/cloud/bigquery/client.py | 2 +- core/google/cloud/client.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bigquery/google/cloud/bigquery/client.py b/bigquery/google/cloud/bigquery/client.py index c6ad1f0a45e1..e298468f0fbb 100644 --- a/bigquery/google/cloud/bigquery/client.py +++ b/bigquery/google/cloud/bigquery/client.py @@ -93,7 +93,7 @@ def from_api_repr(cls, resource): class Client(ClientWithProject): """Client to bundle configuration needed for API requests. - Keyword Args: + Args: project (str): Project ID for the project which the client acts on behalf of. Will be passed when creating a dataset / job. If not passed, diff --git a/core/google/cloud/client.py b/core/google/cloud/client.py index 92e868aa0365..634fce3200a0 100644 --- a/core/google/cloud/client.py +++ b/core/google/cloud/client.py @@ -94,7 +94,7 @@ class Client(_ClientFactoryMixin): Callers and subclasses may seek to use the private key from ``credentials`` to sign data. - Keyword Args: + Args: credentials (google.auth.credentials.Credentials): (Optional) The OAuth2 Credentials to use for this client. If not passed (and if no ``_http`` object is passed), falls back to the @@ -104,8 +104,9 @@ class Client(_ClientFactoryMixin): defines ``request()`` with the same interface as :meth:`requests.Session.request`. If not passed, an ``_http`` object is created that is bound to the ``credentials`` for the - current object. This parameter should be considered private, and - could change in the future. + current object. + This parameter should be considered private, and could change in + the future. Raises: google.auth.exceptions.DefaultCredentialsError: