Skip to content

Commit 5ee56a1

Browse files
chore(python): use black==22.3.0 (#506)
Source-Link: googleapis/synthtool@6fab84a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
1 parent b0df9a6 commit 5ee56a1

15 files changed

Lines changed: 146 additions & 60 deletions

File tree

packages/pandas-gbq/.github/.OwlBot.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3
16+
digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe

packages/pandas-gbq/docs/conf.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@
279279
# (source start file, target name, title,
280280
# author, documentclass [howto, manual, or own class]).
281281
latex_documents = [
282-
(root_doc, "pandas-gbq.tex", "pandas-gbq Documentation", author, "manual",)
282+
(
283+
root_doc,
284+
"pandas-gbq.tex",
285+
"pandas-gbq Documentation",
286+
author,
287+
"manual",
288+
)
283289
]
284290

285291
# The name of an image file (relative to this directory) to place at the top of
@@ -307,7 +313,15 @@
307313

308314
# One entry per manual page. List of tuples
309315
# (source start file, name, description, authors, manual section).
310-
man_pages = [(root_doc, "pandas-gbq", "pandas-gbq Documentation", [author], 1,)]
316+
man_pages = [
317+
(
318+
root_doc,
319+
"pandas-gbq",
320+
"pandas-gbq Documentation",
321+
[author],
322+
1,
323+
)
324+
]
311325

312326
# If true, show URL addresses after external links.
313327
# man_show_urls = False
@@ -347,7 +361,10 @@
347361
intersphinx_mapping = {
348362
"python": ("https://python.readthedocs.org/en/latest/", None),
349363
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
350-
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
364+
"google.api_core": (
365+
"https://googleapis.dev/python/google-api-core/latest/",
366+
None,
367+
),
351368
"grpc": ("https://grpc.github.io/grpc/python/", None),
352369
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
353370
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),

packages/pandas-gbq/noxfile.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import nox
2626

2727

28-
BLACK_VERSION = "black==19.10b0"
28+
BLACK_VERSION = "black==22.3.0"
2929
BLACK_PATHS = ["docs", "pandas_gbq", "tests", "noxfile.py", "setup.py"]
3030

3131
DEFAULT_PYTHON_VERSION = "3.8"
@@ -58,7 +58,9 @@ def lint(session):
5858
"""
5959
session.install("flake8", BLACK_VERSION)
6060
session.run(
61-
"black", "--check", *BLACK_PATHS,
61+
"black",
62+
"--check",
63+
*BLACK_PATHS,
6264
)
6365
session.run("flake8", "pandas_gbq", "tests")
6466

@@ -68,7 +70,8 @@ def blacken(session):
6870
"""Run black. Format code to uniform standard."""
6971
session.install(BLACK_VERSION)
7072
session.run(
71-
"black", *BLACK_PATHS,
73+
"black",
74+
*BLACK_PATHS,
7275
)
7376

7477

packages/pandas-gbq/pandas_gbq/auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def get_credentials_cache(reauth):
5858

5959
if reauth:
6060
return pydata_google_auth.cache.WriteOnlyCredentialsCache(
61-
dirname=CREDENTIALS_CACHE_DIRNAME, filename=CREDENTIALS_CACHE_FILENAME,
61+
dirname=CREDENTIALS_CACHE_DIRNAME,
62+
filename=CREDENTIALS_CACHE_FILENAME,
6263
)
6364
return pydata_google_auth.cache.ReadWriteCredentialsCache(
6465
dirname=CREDENTIALS_CACHE_DIRNAME, filename=CREDENTIALS_CACHE_FILENAME

packages/pandas-gbq/pandas_gbq/gbq.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def __init__(
338338

339339
# BQ Queries costs $5 per TB. First 1 TB per month is free
340340
# see here for more: https://cloud.google.com/bigquery/pricing
341-
self.query_price_for_TB = 5.0 / 2 ** 40 # USD/TB
341+
self.query_price_for_TB = 5.0 / 2**40 # USD/TB
342342

343343
def _start_timer(self):
344344
self.start = time.time()
@@ -500,7 +500,8 @@ def run_query(self, query, max_results=None, progress_bar_type=None, **kwargs):
500500
bytes_billed = query_reply.total_bytes_billed or 0
501501
logger.debug(
502502
"Query done.\nProcessed: {} Billed: {}".format(
503-
self.sizeof_fmt(bytes_processed), self.sizeof_fmt(bytes_billed),
503+
self.sizeof_fmt(bytes_processed),
504+
self.sizeof_fmt(bytes_billed),
504505
)
505506
)
506507
logger.debug(
@@ -533,7 +534,11 @@ def run_query(self, query, max_results=None, progress_bar_type=None, **kwargs):
533534
)
534535

535536
def _download_results(
536-
self, rows_iter, max_results=None, progress_bar_type=None, user_dtypes=None,
537+
self,
538+
rows_iter,
539+
max_results=None,
540+
progress_bar_type=None,
541+
user_dtypes=None,
537542
):
538543
# No results are desired, so don't bother downloading anything.
539544
if max_results == 0:
@@ -1309,7 +1314,9 @@ def create(self, table_id, schema):
13091314
self.dataset_id
13101315
):
13111316
_Dataset(
1312-
self.project_id, credentials=self.credentials, location=self.location,
1317+
self.project_id,
1318+
credentials=self.credentials,
1319+
location=self.location,
13131320
).create(self.dataset_id)
13141321

13151322
table_ref = TableReference(

packages/pandas-gbq/pandas_gbq/load.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def split_dataframe(dataframe, chunksize=None):
5959

6060

6161
def cast_dataframe_for_parquet(
62-
dataframe: pandas.DataFrame, schema: Optional[Dict[str, Any]],
62+
dataframe: pandas.DataFrame,
63+
schema: Optional[Dict[str, Any]],
6364
) -> pandas.DataFrame:
6465
"""Cast columns to needed dtype when writing parquet files.
6566

packages/pandas-gbq/samples/snippets/noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# WARNING - WARNING - WARNING - WARNING - WARNING
3030
# WARNING - WARNING - WARNING - WARNING - WARNING
3131

32-
BLACK_VERSION = "black==19.10b0"
32+
BLACK_VERSION = "black==22.3.0"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None:
253253

254254

255255
def _get_repo_root() -> Optional[str]:
256-
""" Returns the root folder of the project. """
256+
"""Returns the root folder of the project."""
257257
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
258258
p = Path(os.getcwd())
259259
for i in range(10):

packages/pandas-gbq/tests/system/test_gbq.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def get_schema(gbq_connector: gbq.GbqConnector, dataset_id: str, table_id: str):
8787

8888
bqclient = gbq_connector.client
8989
table_ref = bigquery.TableReference(
90-
bigquery.DatasetReference(bqclient.project, dataset_id), table_id,
90+
bigquery.DatasetReference(bqclient.project, dataset_id),
91+
table_id,
9192
)
9293

9394
try:
@@ -518,7 +519,8 @@ def test_array(self, project_id):
518519
dialect="standard",
519520
)
520521
tm.assert_frame_equal(
521-
df, DataFrame([[["a", "x", "b", "y", "c", "z"]]], columns=["letters"]),
522+
df,
523+
DataFrame([[["a", "x", "b", "y", "c", "z"]]], columns=["letters"]),
522524
)
523525

524526
def test_array_length_zero(self, project_id):
@@ -565,7 +567,8 @@ def test_array_agg(self, project_id):
565567
dialect="standard",
566568
)
567569
tm.assert_frame_equal(
568-
df, DataFrame([["a", [1, 3]], ["b", [2]]], columns=["letter", "numbers"]),
570+
df,
571+
DataFrame([["a", [1, 3]], ["b", [2]]], columns=["letter", "numbers"]),
569572
)
570573

571574
def test_array_of_floats(self, project_id):
@@ -990,7 +993,9 @@ def test_upload_data_with_timestamp(self, project_id):
990993
test_id = "21"
991994
test_size = 6
992995
df = DataFrame(
993-
np.random.randn(test_size, 4), index=range(test_size), columns=list("ABCD"),
996+
np.random.randn(test_size, 4),
997+
index=range(test_size),
998+
columns=list("ABCD"),
994999
)
9951000
df["times"] = pandas.Series(
9961001
[
@@ -1069,7 +1074,8 @@ def test_upload_data_tokyo(self, project_id, tokyo_dataset, bigquery_client):
10691074

10701075
table = bigquery_client.get_table(
10711076
bigquery.TableReference(
1072-
bigquery.DatasetReference(project_id, tokyo_dataset), "to_gbq_test",
1077+
bigquery.DatasetReference(project_id, tokyo_dataset),
1078+
"to_gbq_test",
10731079
)
10741080
)
10751081
assert table.num_rows > 0

packages/pandas-gbq/tests/system/test_read_gbq.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def writable_table(
153153
),
154154
"float_col": [1.125, -2.375, 0.0],
155155
"int64_col": pandas.Series(
156-
[(2 ** 63) - 1, -1, -(2 ** 63)], dtype="Int64"
156+
[(2**63) - 1, -1, -(2**63)], dtype="Int64"
157157
),
158158
"numeric_col": [
159159
decimal.Decimal("123.456789"),
@@ -377,15 +377,25 @@ def writable_table(
377377
else "object",
378378
),
379379
"bytes_col": [None],
380-
"date_col": pandas.Series([None], dtype=db_dtypes.DateDtype(),),
381-
"datetime_col": pandas.Series([None], dtype="datetime64[ns]",),
380+
"date_col": pandas.Series(
381+
[None],
382+
dtype=db_dtypes.DateDtype(),
383+
),
384+
"datetime_col": pandas.Series(
385+
[None],
386+
dtype="datetime64[ns]",
387+
),
382388
"float_col": pandas.Series([None], dtype="float64"),
383389
"int64_col": pandas.Series([None], dtype="Int64"),
384390
"numeric_col": [None],
385391
"string_col": [None],
386-
"time_col": pandas.Series([None], dtype=db_dtypes.TimeDtype(),),
392+
"time_col": pandas.Series(
393+
[None],
394+
dtype=db_dtypes.TimeDtype(),
395+
),
387396
"timestamp_col": pandas.Series(
388-
[None], dtype="datetime64[ns]",
397+
[None],
398+
dtype="datetime64[ns]",
389399
).dt.tz_localize(datetime.timezone.utc),
390400
}
391401
),
@@ -605,19 +615,30 @@ def test_empty_dataframe(read_gbq, use_bqstorage_api):
605615
{
606616
"row_num": pandas.Series([], dtype="Int64"),
607617
"bool_col": pandas.Series(
608-
[], dtype="boolean" if FEATURES.pandas_has_boolean_dtype else "bool",
618+
[],
619+
dtype="boolean" if FEATURES.pandas_has_boolean_dtype else "bool",
609620
),
610621
"bytes_col": pandas.Series([], dtype="object"),
611-
"date_col": pandas.Series([], dtype=db_dtypes.DateDtype(),),
612-
"datetime_col": pandas.Series([], dtype="datetime64[ns]",),
622+
"date_col": pandas.Series(
623+
[],
624+
dtype=db_dtypes.DateDtype(),
625+
),
626+
"datetime_col": pandas.Series(
627+
[],
628+
dtype="datetime64[ns]",
629+
),
613630
"float_col": pandas.Series([], dtype="float64"),
614631
"int64_col": pandas.Series([], dtype="Int64"),
615632
"numeric_col": pandas.Series([], dtype="object"),
616633
"string_col": pandas.Series([], dtype="object"),
617-
"time_col": pandas.Series([], dtype=db_dtypes.TimeDtype(),),
618-
"timestamp_col": pandas.Series([], dtype="datetime64[ns]",).dt.tz_localize(
619-
datetime.timezone.utc
634+
"time_col": pandas.Series(
635+
[],
636+
dtype=db_dtypes.TimeDtype(),
620637
),
638+
"timestamp_col": pandas.Series(
639+
[],
640+
dtype="datetime64[ns]",
641+
).dt.tz_localize(datetime.timezone.utc),
621642
}
622643
)
623644
result = read_gbq(query, use_bqstorage_api=use_bqstorage_api)

packages/pandas-gbq/tests/system/test_read_gbq_with_bqstorage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ def test_empty_results(method_under_test, query_string):
3636
3737
See: https://github.com/pydata/pandas-gbq/issues/299
3838
"""
39-
df = method_under_test(query_string, use_bqstorage_api=True,)
39+
df = method_under_test(
40+
query_string,
41+
use_bqstorage_api=True,
42+
)
4043
assert len(df.index) == 0
4144

4245

0 commit comments

Comments
 (0)