Skip to content

chore(python): use black==22.3.0 #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions db_dtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)


Expand Down Expand Up @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions db_dtypes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 20 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
9 changes: 6 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")

Expand All @@ -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,
)


Expand Down
4 changes: 2 additions & 2 deletions samples/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion samples/snippets/pandas_date_and_time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 20 additions & 8 deletions tests/unit/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
),
(
Expand All @@ -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)],
Expand Down Expand Up @@ -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(),
),
),
(
Expand All @@ -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)],
Expand All @@ -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)],
Expand Down Expand Up @@ -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(
[
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]),
)


Expand Down Expand Up @@ -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),
)


Expand Down