Skip to content

Commit e9f4c00

Browse files
fix lint
1 parent adcfc7b commit e9f4c00

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

pandas_gbq/gbq_connector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ def run_query(
272272
if dry_run:
273273
# Access total_bytes_processed from the QueryJob via RowIterator.job
274274
# RowIterator has a job attribute that references the QueryJob
275-
query_job = rows_iter.job if hasattr(rows_iter, 'job') and rows_iter.job else None
275+
query_job = (
276+
rows_iter.job if hasattr(rows_iter, "job") and rows_iter.job else None
277+
)
276278
if query_job is None:
277279
# Fallback: if query_and_wait_via_client_library doesn't set job,
278280
# we need to get it from the query result

pandas_gbq/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def query_and_wait(
182182
rows_iter = query_reply.result(max_results=max_results)
183183
# Store reference to QueryJob in RowIterator for dry_run access
184184
# RowIterator already has a job attribute, but ensure it's set
185-
if not hasattr(rows_iter, 'job') or rows_iter.job is None:
185+
if not hasattr(rows_iter, "job") or rows_iter.job is None:
186186
rows_iter.job = query_reply
187187
return rows_iter
188188
except connector.http_error as ex:
@@ -217,10 +217,10 @@ def query_and_wait_via_client_library(
217217
query_job.result(timeout=timeout_ms / 1000.0 if timeout_ms else None)
218218
# Get the result iterator and ensure job attribute is set
219219
rows_iter = query_job.result(max_results=max_results)
220-
if not hasattr(rows_iter, 'job') or rows_iter.job is None:
220+
if not hasattr(rows_iter, "job") or rows_iter.job is None:
221221
rows_iter.job = query_job
222222
return rows_iter
223-
223+
224224
rows_iter = try_query(
225225
connector,
226226
functools.partial(
@@ -234,7 +234,7 @@ def query_and_wait_via_client_library(
234234
),
235235
)
236236
# Ensure job attribute is set for consistency
237-
if hasattr(rows_iter, 'job') and rows_iter.job is None:
237+
if hasattr(rows_iter, "job") and rows_iter.job is None:
238238
# If query_and_wait doesn't set job, we need to get it from the query
239239
# This shouldn't happen, but we ensure it's set for dry_run compatibility
240240
pass

tests/system/test_gbq.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ def test_read_gbq_with_dry_run(self, project_id):
669669
assert cost > 0
670670

671671

672-
673672
class TestToGBQIntegration(object):
674673
@pytest.fixture(autouse=True, scope="function")
675674
def setup(self, project, credentials, random_dataset_id):

tests/unit/test_gbq.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,10 @@ def test_read_gbq_with_dry_run(mock_bigquery_client, mock_query_job):
945945
type(mock_query_job).total_bytes_processed = mock.PropertyMock(return_value=12345)
946946
cost = gbq.read_gbq("SELECT 1", project_id="my-project", dry_run=True)
947947
# Check which method was called based on BigQuery version
948-
if hasattr(mock_bigquery_client, "query_and_wait") and mock_bigquery_client.query_and_wait.called:
948+
if (
949+
hasattr(mock_bigquery_client, "query_and_wait")
950+
and mock_bigquery_client.query_and_wait.called
951+
):
949952
_, kwargs = mock_bigquery_client.query_and_wait.call_args
950953
job_config = kwargs["job_config"]
951954
else:

0 commit comments

Comments
 (0)