Skip to content

Commit a92614b

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

File tree

9 files changed

+65
-24
lines changed

9 files changed

+65
-24
lines changed

.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

db_dtypes/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ def __arrow_array__(self, type=None):
197197
# since the datetime epoch (midnight 1970-01-01).
198198
array = array.view(pyarrow.time64("ns"))
199199
return pyarrow.compute.cast(
200-
array, type if type is not None else pyarrow.time64("ns"),
200+
array,
201+
type if type is not None else pyarrow.time64("ns"),
201202
)
202203

203204

@@ -297,7 +298,8 @@ def __arrow_array__(self, type=None):
297298
"""
298299
array = pyarrow.array(self._ndarray, type=pyarrow.timestamp("ns"))
299300
return pyarrow.compute.cast(
300-
array, type if type is not None else pyarrow.date32(),
301+
array,
302+
type if type is not None else pyarrow.date32(),
301303
)
302304

303305
def __add__(self, other):

db_dtypes/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def __init__(self, values, dtype=None, copy: bool = False):
6464

6565
@classmethod
6666
def __ndarray(cls, scalars):
67-
return numpy.array([cls._datetime(scalar) for scalar in scalars], "M8[ns]",)
67+
return numpy.array(
68+
[cls._datetime(scalar) for scalar in scalars],
69+
"M8[ns]",
70+
)
6871

6972
@classmethod
7073
def _from_sequence(cls, scalars, *, dtype=None, copy=False):
@@ -186,7 +189,8 @@ def median(
186189
raise NotImplementedError("Need pandas 1.3 or later to calculate median.")
187190

188191
pandas_backports.numpy_validate_median(
189-
(), {"out": out, "overwrite_input": overwrite_input, "keepdims": keepdims},
192+
(),
193+
{"out": out, "overwrite_input": overwrite_input, "keepdims": keepdims},
190194
)
191195
result = pandas_backports.nanmedian(self._ndarray, axis=axis, skipna=skipna)
192196
if axis is None or self.ndim == 1:

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, "db-dtypes.tex", "db-dtypes Documentation", author, "manual",)
282+
(
283+
root_doc,
284+
"db-dtypes.tex",
285+
"db-dtypes 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, "db-dtypes", "db-dtypes Documentation", [author], 1,)]
316+
man_pages = [
317+
(
318+
root_doc,
319+
"db-dtypes",
320+
"db-dtypes 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),

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", "db_dtypes", "tests", "noxfile.py", "setup.py"]
3030

3131
DEFAULT_PYTHON_VERSION = "3.8"
@@ -60,7 +60,9 @@ def lint(session):
6060
"""
6161
session.install("flake8", BLACK_VERSION)
6262
session.run(
63-
"black", "--check", *BLACK_PATHS,
63+
"black",
64+
"--check",
65+
*BLACK_PATHS,
6466
)
6567
session.run("flake8", "db_dtypes", "tests")
6668

@@ -70,7 +72,8 @@ def blacken(session):
7072
"""Run black. Format code to uniform standard."""
7173
session.install(BLACK_VERSION)
7274
session.run(
73-
"black", *BLACK_PATHS,
75+
"black",
76+
*BLACK_PATHS,
7477
)
7578

7679

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):

samples/snippets/pandas_date_and_time_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_pandas_date_and_time():
3939
assert list(dates) == [datetime.date(2021, 9, 17), datetime.date(2021, 9, 18)]
4040

4141
assert np.array_equal(
42-
diffs, dates.astype("datetime64") - dates2.astype("datetime64"),
42+
diffs,
43+
dates.astype("datetime64") - dates2.astype("datetime64"),
4344
)
4445

4546
assert np.array_equal(after, dates.astype("object") + do)

tests/unit/test_arrow.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def types_mapper(
5454
[dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], dtype="dbdate"
5555
),
5656
pyarrow.array(
57-
[dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], type=pyarrow.date32(),
57+
[dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)],
58+
type=pyarrow.date32(),
5859
),
5960
),
6061
(
@@ -67,14 +68,18 @@ def types_mapper(
6768
type=pyarrow.date32(),
6869
),
6970
),
70-
(pandas.Series([], dtype="dbtime"), pyarrow.array([], type=pyarrow.time64("ns")),),
71+
(
72+
pandas.Series([], dtype="dbtime"),
73+
pyarrow.array([], type=pyarrow.time64("ns")),
74+
),
7175
(
7276
pandas.Series([None, None, None], dtype="dbtime"),
7377
pyarrow.array([None, None, None], type=pyarrow.time64("ns")),
7478
),
7579
(
7680
pandas.Series(
77-
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], dtype="dbtime",
81+
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)],
82+
dtype="dbtime",
7883
),
7984
pyarrow.array(
8085
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)],
@@ -111,7 +116,8 @@ def types_mapper(
111116
[dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], dtype="dbdate"
112117
),
113118
pyarrow.array(
114-
[dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], type=pyarrow.date64(),
119+
[dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)],
120+
type=pyarrow.date64(),
115121
),
116122
),
117123
(
@@ -124,14 +130,18 @@ def types_mapper(
124130
type=pyarrow.date64(),
125131
),
126132
),
127-
(pandas.Series([], dtype="dbtime"), pyarrow.array([], type=pyarrow.time32("ms")),),
133+
(
134+
pandas.Series([], dtype="dbtime"),
135+
pyarrow.array([], type=pyarrow.time32("ms")),
136+
),
128137
(
129138
pandas.Series([None, None, None], dtype="dbtime"),
130139
pyarrow.array([None, None, None], type=pyarrow.time32("ms")),
131140
),
132141
(
133142
pandas.Series(
134-
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_000)], dtype="dbtime",
143+
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_000)],
144+
dtype="dbtime",
135145
),
136146
pyarrow.array(
137147
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_000)],
@@ -158,7 +168,8 @@ def types_mapper(
158168
),
159169
(
160170
pandas.Series(
161-
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], dtype="dbtime",
171+
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)],
172+
dtype="dbtime",
162173
),
163174
pyarrow.array(
164175
[dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)],
@@ -220,7 +231,8 @@ def types_mapper(
220231
),
221232
pytest.param(
222233
pandas.Series(
223-
["0:0:0", "12:30:15.123456789", "23:59:59.999999999"], dtype="dbtime",
234+
["0:0:0", "12:30:15.123456789", "23:59:59.999999999"],
235+
dtype="dbtime",
224236
),
225237
pyarrow.array(
226238
[

tests/unit/test_dtypes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def test___getitem___arrayindex(dtype):
201201
cls = _cls(dtype)
202202
sample_values = SAMPLE_VALUES[dtype]
203203
np.testing.assert_array_equal(
204-
cls(sample_values)[[1, 3]], cls([sample_values[1], sample_values[3]]),
204+
cls(sample_values)[[1, 3]],
205+
cls([sample_values[1], sample_values[3]]),
205206
)
206207

207208

@@ -410,7 +411,8 @@ def test_unique(dtype):
410411
cls = _cls(dtype)
411412
sample_values = SAMPLE_VALUES[dtype]
412413
np.testing.assert_array_equal(
413-
cls(sample_values * 3).unique(), cls(sample_values),
414+
cls(sample_values * 3).unique(),
415+
cls(sample_values),
414416
)
415417

416418

0 commit comments

Comments
 (0)