Skip to content

Commit 4206fd4

Browse files
alimcmaster1jreback
authored andcommitted
TPY: Add Types to gbq.py (#30632)
1 parent c22d022 commit 4206fd4

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

pandas/io/gbq.py

+29-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
""" Google BigQuery support """
2+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
3+
24
from pandas.compat._optional import import_optional_dependency
35

6+
if TYPE_CHECKING:
7+
from pandas import DataFrame
8+
49

510
def _try_import():
611
# since pandas is a dependency of pandas-gbq
@@ -14,21 +19,21 @@ def _try_import():
1419

1520

1621
def read_gbq(
17-
query,
18-
project_id=None,
19-
index_col=None,
20-
col_order=None,
21-
reauth=False,
22-
auth_local_webserver=False,
23-
dialect=None,
24-
location=None,
25-
configuration=None,
22+
query: str,
23+
project_id: Optional[str] = None,
24+
index_col: Optional[str] = None,
25+
col_order: Optional[List[str]] = None,
26+
reauth: bool = False,
27+
auth_local_webserver: bool = False,
28+
dialect: Optional[str] = None,
29+
location: Optional[str] = None,
30+
configuration: Optional[Dict[str, Any]] = None,
2631
credentials=None,
27-
use_bqstorage_api=None,
32+
use_bqstorage_api: Optional[bool] = None,
2833
private_key=None,
2934
verbose=None,
30-
progress_bar_type=None,
31-
):
35+
progress_bar_type: Optional[str] = None,
36+
) -> "DataFrame":
3237
"""
3338
Load data from Google BigQuery.
3439
@@ -157,7 +162,7 @@ def read_gbq(
157162
"""
158163
pandas_gbq = _try_import()
159164

160-
kwargs = {}
165+
kwargs: Dict[str, Union[str, bool]] = {}
161166

162167
# START: new kwargs. Don't populate unless explicitly set.
163168
if use_bqstorage_api is not None:
@@ -183,20 +188,20 @@ def read_gbq(
183188

184189

185190
def to_gbq(
186-
dataframe,
187-
destination_table,
188-
project_id=None,
189-
chunksize=None,
190-
reauth=False,
191-
if_exists="fail",
192-
auth_local_webserver=False,
193-
table_schema=None,
194-
location=None,
195-
progress_bar=True,
191+
dataframe: "DataFrame",
192+
destination_table: str,
193+
project_id: Optional[str] = None,
194+
chunksize: Optional[int] = None,
195+
reauth: bool = False,
196+
if_exists: str = "fail",
197+
auth_local_webserver: bool = False,
198+
table_schema: Optional[List[Dict[str, str]]] = None,
199+
location: Optional[str] = None,
200+
progress_bar: bool = True,
196201
credentials=None,
197202
verbose=None,
198203
private_key=None,
199-
):
204+
) -> None:
200205
pandas_gbq = _try_import()
201206
pandas_gbq.to_gbq(
202207
dataframe,

0 commit comments

Comments
 (0)