Skip to content

Commit b91ed19

Browse files
rinarakakiparthea
andauthored
fix: add type hints to ClientOptions (#735)
* Update * Update client_options.py * Update * fix build --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 46b3d3a commit b91ed19

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

google/api_core/client_options.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@ def get_client_cert():
4848
4949
"""
5050

51+
from typing import Callable, Mapping, Optional, Sequence, Tuple
52+
5153

5254
class ClientOptions(object):
5355
"""Client Options used to set options on clients.
5456
5557
Args:
5658
api_endpoint (Optional[str]): The desired API endpoint, e.g.,
5759
compute.googleapis.com
58-
client_cert_source (Optional[Callable[[], (bytes, bytes)]]): A callback
60+
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback
5961
which returns client certificate bytes and private key bytes both in
6062
PEM format. ``client_cert_source`` and ``client_encrypted_cert_source``
6163
are mutually exclusive.
62-
client_encrypted_cert_source (Optional[Callable[[], (str, str, bytes)]]):
64+
client_encrypted_cert_source (Optional[Callable[[], Tuple[str, str, bytes]]]):
6365
A callback which returns client certificate file path, encrypted
6466
private key file path, and the passphrase bytes.``client_cert_source``
6567
and ``client_encrypted_cert_source`` are mutually exclusive.
@@ -88,15 +90,17 @@ class ClientOptions(object):
8890

8991
def __init__(
9092
self,
91-
api_endpoint=None,
92-
client_cert_source=None,
93-
client_encrypted_cert_source=None,
94-
quota_project_id=None,
95-
credentials_file=None,
96-
scopes=None,
97-
api_key=None,
98-
api_audience=None,
99-
universe_domain=None,
93+
api_endpoint: Optional[str] = None,
94+
client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
95+
client_encrypted_cert_source: Optional[
96+
Callable[[], Tuple[str, str, bytes]]
97+
] = None,
98+
quota_project_id: Optional[str] = None,
99+
credentials_file: Optional[str] = None,
100+
scopes: Optional[Sequence[str]] = None,
101+
api_key: Optional[str] = None,
102+
api_audience: Optional[str] = None,
103+
universe_domain: Optional[str] = None,
100104
):
101105
if client_cert_source and client_encrypted_cert_source:
102106
raise ValueError(
@@ -114,11 +118,11 @@ def __init__(
114118
self.api_audience = api_audience
115119
self.universe_domain = universe_domain
116120

117-
def __repr__(self):
121+
def __repr__(self) -> str:
118122
return "ClientOptions: " + repr(self.__dict__)
119123

120124

121-
def from_dict(options):
125+
def from_dict(options: Mapping[str, object]) -> ClientOptions:
122126
"""Construct a client options object from a mapping object.
123127
124128
Args:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy