diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7..87dd006 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/db_dtypes/__init__.py b/db_dtypes/__init__.py index 7889dac..ca0b468 100644 --- a/db_dtypes/__init__.py +++ b/db_dtypes/__init__.py @@ -197,7 +197,8 @@ def __arrow_array__(self, type=None): # since the datetime epoch (midnight 1970-01-01). array = array.view(pyarrow.time64("ns")) return pyarrow.compute.cast( - array, type if type is not None else pyarrow.time64("ns"), + array, + type if type is not None else pyarrow.time64("ns"), ) @@ -297,7 +298,8 @@ def __arrow_array__(self, type=None): """ array = pyarrow.array(self._ndarray, type=pyarrow.timestamp("ns")) return pyarrow.compute.cast( - array, type if type is not None else pyarrow.date32(), + array, + type if type is not None else pyarrow.date32(), ) def __add__(self, other): diff --git a/db_dtypes/core.py b/db_dtypes/core.py index 68123e1..e9ab4ad 100644 --- a/db_dtypes/core.py +++ b/db_dtypes/core.py @@ -64,7 +64,10 @@ def __init__(self, values, dtype=None, copy: bool = False): @classmethod def __ndarray(cls, scalars): - return numpy.array([cls._datetime(scalar) for scalar in scalars], "M8[ns]",) + return numpy.array( + [cls._datetime(scalar) for scalar in scalars], + "M8[ns]", + ) @classmethod def _from_sequence(cls, scalars, *, dtype=None, copy=False): @@ -186,7 +189,8 @@ def median( raise NotImplementedError("Need pandas 1.3 or later to calculate median.") pandas_backports.numpy_validate_median( - (), {"out": out, "overwrite_input": overwrite_input, "keepdims": keepdims}, + (), + {"out": out, "overwrite_input": overwrite_input, "keepdims": keepdims}, ) result = pandas_backports.nanmedian(self._ndarray, axis=axis, skipna=skipna) if axis is None or self.ndim == 1: diff --git a/docs/conf.py b/docs/conf.py index 5cf73ba..0565c61 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -279,7 +279,13 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (root_doc, "db-dtypes.tex", "db-dtypes Documentation", author, "manual",) + ( + root_doc, + "db-dtypes.tex", + "db-dtypes Documentation", + author, + "manual", + ) ] # The name of an image file (relative to this directory) to place at the top of @@ -307,7 +313,15 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(root_doc, "db-dtypes", "db-dtypes Documentation", [author], 1,)] +man_pages = [ + ( + root_doc, + "db-dtypes", + "db-dtypes Documentation", + [author], + 1, + ) +] # If true, show URL addresses after external links. # man_show_urls = False @@ -347,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/noxfile.py b/noxfile.py index 0ab6290..d529185 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,7 +25,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "db_dtypes", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -60,7 +60,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "db_dtypes", "tests") @@ -70,7 +72,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 85f5836..25f87a2 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/samples/snippets/pandas_date_and_time_test.py b/samples/snippets/pandas_date_and_time_test.py index 6f78240..50c56d5 100644 --- a/samples/snippets/pandas_date_and_time_test.py +++ b/samples/snippets/pandas_date_and_time_test.py @@ -39,7 +39,8 @@ def test_pandas_date_and_time(): assert list(dates) == [datetime.date(2021, 9, 17), datetime.date(2021, 9, 18)] assert np.array_equal( - diffs, dates.astype("datetime64") - dates2.astype("datetime64"), + diffs, + dates.astype("datetime64") - dates2.astype("datetime64"), ) assert np.array_equal(after, dates.astype("object") + do) diff --git a/tests/unit/test_arrow.py b/tests/unit/test_arrow.py index 4d4fc50..56bbd01 100644 --- a/tests/unit/test_arrow.py +++ b/tests/unit/test_arrow.py @@ -54,7 +54,8 @@ def types_mapper( [dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], dtype="dbdate" ), pyarrow.array( - [dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], type=pyarrow.date32(), + [dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], + type=pyarrow.date32(), ), ), ( @@ -67,14 +68,18 @@ def types_mapper( type=pyarrow.date32(), ), ), - (pandas.Series([], dtype="dbtime"), pyarrow.array([], type=pyarrow.time64("ns")),), + ( + pandas.Series([], dtype="dbtime"), + pyarrow.array([], type=pyarrow.time64("ns")), + ), ( pandas.Series([None, None, None], dtype="dbtime"), pyarrow.array([None, None, None], type=pyarrow.time64("ns")), ), ( pandas.Series( - [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], dtype="dbtime", + [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], + dtype="dbtime", ), pyarrow.array( [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], @@ -111,7 +116,8 @@ def types_mapper( [dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], dtype="dbdate" ), pyarrow.array( - [dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], type=pyarrow.date64(), + [dt.date(2021, 9, 27), None, dt.date(2011, 9, 27)], + type=pyarrow.date64(), ), ), ( @@ -124,14 +130,18 @@ def types_mapper( type=pyarrow.date64(), ), ), - (pandas.Series([], dtype="dbtime"), pyarrow.array([], type=pyarrow.time32("ms")),), + ( + pandas.Series([], dtype="dbtime"), + pyarrow.array([], type=pyarrow.time32("ms")), + ), ( pandas.Series([None, None, None], dtype="dbtime"), pyarrow.array([None, None, None], type=pyarrow.time32("ms")), ), ( pandas.Series( - [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_000)], dtype="dbtime", + [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_000)], + dtype="dbtime", ), pyarrow.array( [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_000)], @@ -158,7 +168,8 @@ def types_mapper( ), ( pandas.Series( - [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], dtype="dbtime", + [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], + dtype="dbtime", ), pyarrow.array( [dt.time(0, 0, 0, 0), None, dt.time(23, 59, 59, 999_999)], @@ -220,7 +231,8 @@ def types_mapper( ), pytest.param( pandas.Series( - ["0:0:0", "12:30:15.123456789", "23:59:59.999999999"], dtype="dbtime", + ["0:0:0", "12:30:15.123456789", "23:59:59.999999999"], + dtype="dbtime", ), pyarrow.array( [ diff --git a/tests/unit/test_dtypes.py b/tests/unit/test_dtypes.py index dc1613b..6584cee 100644 --- a/tests/unit/test_dtypes.py +++ b/tests/unit/test_dtypes.py @@ -201,7 +201,8 @@ def test___getitem___arrayindex(dtype): cls = _cls(dtype) sample_values = SAMPLE_VALUES[dtype] np.testing.assert_array_equal( - cls(sample_values)[[1, 3]], cls([sample_values[1], sample_values[3]]), + cls(sample_values)[[1, 3]], + cls([sample_values[1], sample_values[3]]), ) @@ -410,7 +411,8 @@ def test_unique(dtype): cls = _cls(dtype) sample_values = SAMPLE_VALUES[dtype] np.testing.assert_array_equal( - cls(sample_values * 3).unique(), cls(sample_values), + cls(sample_values * 3).unique(), + cls(sample_values), )