|
44 | 44 | import uuid |
45 | 45 | import warnings |
46 | 46 |
|
| 47 | +import requests |
| 48 | + |
47 | 49 | from google import resumable_media # type: ignore |
48 | 50 | from google.resumable_media.requests import MultipartUpload # type: ignore |
49 | 51 | from google.resumable_media.requests import ResumableUpload |
|
65 | 67 | DEFAULT_BQSTORAGE_CLIENT_INFO = None # type: ignore |
66 | 68 |
|
67 | 69 |
|
| 70 | +from google.auth.credentials import Credentials |
68 | 71 | from google.cloud.bigquery._http import Connection |
69 | 72 | from google.cloud.bigquery import _job_helpers |
70 | 73 | from google.cloud.bigquery import _pandas_helpers |
|
126 | 129 | _versions_helpers.PANDAS_VERSIONS.try_import() |
127 | 130 | ) # mypy check fails because pandas import is outside module, there are type: ignore comments related to this |
128 | 131 |
|
| 132 | + |
129 | 133 | ResumableTimeoutType = Union[ |
130 | 134 | None, float, Tuple[float, float] |
131 | 135 | ] # for resumable media methods |
132 | 136 |
|
133 | 137 | if typing.TYPE_CHECKING: # pragma: NO COVER |
134 | 138 | # os.PathLike is only subscriptable in Python 3.9+, thus shielding with a condition. |
135 | 139 | PathType = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]] |
136 | | - import requests # required by api-core |
137 | | - |
138 | 140 | _DEFAULT_CHUNKSIZE = 100 * 1024 * 1024 # 100 MB |
139 | 141 | _MAX_MULTIPART_SIZE = 5 * 1024 * 1024 |
140 | 142 | _DEFAULT_NUM_RETRIES = 6 |
@@ -231,30 +233,34 @@ class Client(ClientWithProject): |
231 | 233 |
|
232 | 234 | def __init__( |
233 | 235 | self, |
234 | | - project=None, |
235 | | - credentials=None, |
236 | | - _http=None, |
237 | | - location=None, |
238 | | - default_query_job_config=None, |
239 | | - default_load_job_config=None, |
240 | | - client_info=None, |
241 | | - client_options=None, |
| 236 | + project: Optional[str] = None, |
| 237 | + credentials: Optional[Credentials] = None, |
| 238 | + _http: Optional[requests.Session] = None, |
| 239 | + location: Optional[str] = None, |
| 240 | + default_query_job_config: Optional[QueryJobConfig] = None, |
| 241 | + default_load_job_config: Optional[LoadJobConfig] = None, |
| 242 | + client_info: Optional[google.api_core.client_info.ClientInfo] = None, |
| 243 | + client_options: Optional[ |
| 244 | + Union[google.api_core.client_options.ClientOptions, Dict[str, Any]] |
| 245 | + ] = None, |
242 | 246 | ) -> None: |
| 247 | + if client_options is None: |
| 248 | + client_options = {} |
| 249 | + if isinstance(client_options, dict): |
| 250 | + client_options = google.api_core.client_options.from_dict(client_options) |
| 251 | + # assert isinstance(client_options, google.api_core.client_options.ClientOptions) |
| 252 | + |
243 | 253 | super(Client, self).__init__( |
244 | 254 | project=project, |
245 | 255 | credentials=credentials, |
246 | 256 | client_options=client_options, |
247 | 257 | _http=_http, |
248 | 258 | ) |
249 | 259 |
|
250 | | - kw_args = {"client_info": client_info} |
| 260 | + kw_args: Dict[str, Any] = {"client_info": client_info} |
251 | 261 | bq_host = _get_bigquery_host() |
252 | 262 | kw_args["api_endpoint"] = bq_host if bq_host != _DEFAULT_HOST else None |
253 | 263 | client_universe = None |
254 | | - if client_options is None: |
255 | | - client_options = {} |
256 | | - if isinstance(client_options, dict): |
257 | | - client_options = google.api_core.client_options.from_dict(client_options) |
258 | 264 | if client_options.api_endpoint: |
259 | 265 | api_endpoint = client_options.api_endpoint |
260 | 266 | kw_args["api_endpoint"] = api_endpoint |
|
0 commit comments