Skip to content

Commit a74b5c0

Browse files
committed
style: run black formatting on modified files
1 parent be85288 commit a74b5c0

2 files changed

Lines changed: 38 additions & 15 deletions

File tree

packages/google-cloud-bigquery/google/cloud/bigquery/table.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,13 +2814,19 @@ def to_dataframe(
28142814
if _versions_helpers.PANDAS_GBQ_VERSIONS.is_delegation_supported:
28152815
import pandas_gbq # type: ignore
28162816

2817-
if self.client and hasattr(self.client, "_connection") and hasattr(self.client._connection, "_client_info"):
2817+
if (
2818+
self.client
2819+
and hasattr(self.client, "_connection")
2820+
and hasattr(self.client._connection, "_client_info")
2821+
):
28182822
client_info = self.client._connection._client_info
28192823
if client_info:
28202824
ua = client_info.user_agent or ""
28212825
if "pandas-gbq" not in ua:
28222826
pandas_gbq_version = getattr(pandas_gbq, "__version__", "0.0.0")
2823-
client_info.user_agent = f"{ua} pandas-gbq/{pandas_gbq_version}".strip()
2827+
client_info.user_agent = (
2828+
f"{ua} pandas-gbq/{pandas_gbq_version}".strip()
2829+
)
28242830

28252831
return pandas_gbq.pandas.from_row_iterator(
28262832
self,

packages/google-cloud-bigquery/tests/unit/test_table.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5722,6 +5722,7 @@ def test_to_dataframe_delegated_when_supported_no_range_types(self):
57225722
import sys
57235723

57245724
import db_dtypes
5725+
57255726
pandas = pytest.importorskip("pandas")
57265727
mock_pandas_gbq = mock.Mock()
57275728
mock_pandas_gbq.pandas.from_row_iterator.return_value = mock.sentinel.dataframe
@@ -5738,10 +5739,11 @@ def test_to_dataframe_delegated_when_supported_no_range_types(self):
57385739
):
57395740
with mock.patch.dict(sys.modules, {"pandas_gbq": mock_pandas_gbq}):
57405741
row_iterator = self._make_one_from_data(
5741-
(("name", "STRING"),),
5742-
(("foo",),)
5742+
(("name", "STRING"),), (("foo",),)
5743+
)
5744+
df = row_iterator.to_dataframe(
5745+
progress_bar_type="tqdm", timeout=5.0
57435746
)
5744-
df = row_iterator.to_dataframe(progress_bar_type="tqdm", timeout=5.0)
57455747

57465748
mock_pandas_gbq.pandas.from_row_iterator.assert_called_once_with(
57475749
row_iterator,
@@ -5769,6 +5771,7 @@ def test_to_dataframe_delegated_when_supported_with_range_types(self):
57695771
import sys
57705772

57715773
import db_dtypes
5774+
57725775
pandas = pytest.importorskip("pandas")
57735776
pyarrow = pytest.importorskip("pyarrow")
57745777
mock_pandas_gbq = mock.Mock()
@@ -5786,19 +5789,32 @@ def test_to_dataframe_delegated_when_supported_with_range_types(self):
57865789
):
57875790
with mock.patch.dict(sys.modules, {"pandas_gbq": mock_pandas_gbq}):
57885791
row_iterator = self._make_one_from_data(
5789-
(("name", "STRING"),),
5790-
(("foo",),)
5792+
(("name", "STRING"),), (("foo",),)
5793+
)
5794+
df = row_iterator.to_dataframe(
5795+
progress_bar_type="tqdm", timeout=5.0
57915796
)
5792-
df = row_iterator.to_dataframe(progress_bar_type="tqdm", timeout=5.0)
57935797

57945798
expected_range_date = pandas.ArrowDtype(
5795-
pyarrow.struct([("start", pyarrow.date32()), ("end", pyarrow.date32())])
5799+
pyarrow.struct(
5800+
[("start", pyarrow.date32()), ("end", pyarrow.date32())]
5801+
)
57965802
)
57975803
expected_range_datetime = pandas.ArrowDtype(
5798-
pyarrow.struct([("start", pyarrow.timestamp("us")), ("end", pyarrow.timestamp("us"))])
5804+
pyarrow.struct(
5805+
[
5806+
("start", pyarrow.timestamp("us")),
5807+
("end", pyarrow.timestamp("us")),
5808+
]
5809+
)
57995810
)
58005811
expected_range_timestamp = pandas.ArrowDtype(
5801-
pyarrow.struct([("start", pyarrow.timestamp("us", tz="UTC")), ("end", pyarrow.timestamp("us", tz="UTC"))])
5812+
pyarrow.struct(
5813+
[
5814+
("start", pyarrow.timestamp("us", tz="UTC")),
5815+
("end", pyarrow.timestamp("us", tz="UTC")),
5816+
]
5817+
)
58025818
)
58035819

58045820
mock_pandas_gbq.pandas.from_row_iterator.assert_called_once_with(
@@ -5825,8 +5841,9 @@ def test_to_dataframe_delegated_when_supported_with_range_types(self):
58255841

58265842
def test_to_dataframe_not_delegated_when_unsupported(self):
58275843
import sys
5844+
58285845
pandas = pytest.importorskip("pandas")
5829-
pyarrow = pytest.importorskip("pyarrow")
5846+
pytest.importorskip("pyarrow")
58305847
mock_pandas_gbq = mock.Mock()
58315848

58325849
with mock.patch(
@@ -5836,8 +5853,7 @@ def test_to_dataframe_not_delegated_when_unsupported(self):
58365853
):
58375854
with mock.patch.dict(sys.modules, {"pandas_gbq": mock_pandas_gbq}):
58385855
row_iterator = self._make_one_from_data(
5839-
(("name", "STRING"),),
5840-
(("foo",),)
5856+
(("name", "STRING"),), (("foo",),)
58415857
)
58425858

58435859
with warnings.catch_warnings(record=True) as warned:
@@ -5849,7 +5865,8 @@ def test_to_dataframe_not_delegated_when_unsupported(self):
58495865
self.assertEqual(df.name.tolist(), ["foo"])
58505866

58515867
deprecation_warnings = [
5852-
w for w in warned
5868+
w
5869+
for w in warned
58535870
if issubclass(w.category, PendingDeprecationWarning)
58545871
and "pandas-gbq" in str(w.message)
58555872
]

0 commit comments

Comments
 (0)