From 3ac3b8d6e1ee5a57a37da97e51ab4704812a3291 Mon Sep 17 00:00:00 2001 From: crusaderky Date: Fri, 25 Nov 2022 16:46:22 +0000 Subject: [PATCH] Bump mypy version (#9697) --- .pre-commit-config.yaml | 33 +++-------------------- dask/dataframe/core.py | 2 -- dask/dataframe/io/tests/test_parquet.py | 5 ++-- dask/tests/test_base.py | 2 +- dask/tests/test_delayed.py | 35 +++++++++++-------------- dask/tests/test_typing.py | 12 +++------ 6 files changed, 28 insertions(+), 61 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 57ec8179d61..f65bb06f3cc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,13 +15,13 @@ repos: - id: isort language_version: python3 - repo: https://github.com/asottile/pyupgrade - rev: v2.38.2 + rev: v3.2.2 hooks: - id: pyupgrade args: - --py38-plus - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black language_version: python3 @@ -38,13 +38,13 @@ repos: # dependency. Make sure to update flake8-bugbear manually on a regular basis. - flake8-bugbear==22.8.23 - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.2 hooks: - id: codespell types_or: [rst, markdown] files: docs - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v0.991 hooks: - id: mypy # Override default --ignore-missing-imports @@ -61,28 +61,3 @@ repos: # Typed libraries - numpy - pytest - - # Work around https://github.com/python/mypy/issues/12286 - # Re-run mypy, checking for Windows-specific issues. - # This section must be kept aligned to the previous one, with the only difference - # of the args. - # Note that we are not checking MacOSX explicitly, as there are typically no - # differences from Linux. - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 - hooks: - - id: mypy - # Override default --ignore-missing-imports - # Use setup.cfg if possible instead of adding command line parameters here - args: [--warn-unused-configs, --platform, win32] - additional_dependencies: - # Type stubs - # - pandas-stubs # TODO - - types-docutils - - types-PyYAML - - types-psutil - - types-requests - - types-setuptools - # Typed libraries - - numpy - - pytest diff --git a/dask/dataframe/core.py b/dask/dataframe/core.py index a043085ebff..93a1dd9c163 100644 --- a/dask/dataframe/core.py +++ b/dask/dataframe/core.py @@ -4406,7 +4406,6 @@ def map(self, arg, na_action=None, meta=no_default, is_monotonic=False): applied = applied.clear_divisions() return applied - # Typing: https://github.com/python/mypy/issues/4125 @property @derived_from(pd.Index) def is_monotonic(self): @@ -4418,7 +4417,6 @@ def is_monotonic(self): ) return super().is_monotonic_increasing - # Typing: https://github.com/python/mypy/issues/1362#issuecomment-208605185 @property @derived_from(pd.Index) def is_monotonic_increasing(self): diff --git a/dask/dataframe/io/tests/test_parquet.py b/dask/dataframe/io/tests/test_parquet.py index c8cb79ed9e6..5eee87f2c4a 100644 --- a/dask/dataframe/io/tests/test_parquet.py +++ b/dask/dataframe/io/tests/test_parquet.py @@ -3736,8 +3736,9 @@ def test_dir_filter(tmpdir, engine): ) ddf = dask.dataframe.from_pandas(df, npartitions=1) ddf.to_parquet(tmpdir, partition_on="year", engine=engine) - dd.read_parquet(tmpdir, filters=[("year", "==", 2020)], engine=engine) - assert all + ddf2 = dd.read_parquet(tmpdir, filters=[("year", "==", 2020)], engine=engine) + ddf2["year"] = ddf2.year.astype("int64") + assert_eq(ddf2, df[df.year == 2020]) @PYARROW_MARK diff --git a/dask/tests/test_base.py b/dask/tests/test_base.py index 39d31cb7a26..9bfad4845d5 100644 --- a/dask/tests/test_base.py +++ b/dask/tests/test_base.py @@ -663,7 +663,7 @@ def __dask_graph__(self): def test_unpack_collections(): class ANamedTuple(NamedTuple): - a: int + a: int # type: ignore[annotation-unchecked] a = delayed(1) + 5 b = a + 1 diff --git a/dask/tests/test_delayed.py b/dask/tests/test_delayed.py index 99dc844d5b8..6e476ad7ef9 100644 --- a/dask/tests/test_delayed.py +++ b/dask/tests/test_delayed.py @@ -3,7 +3,7 @@ from collections import namedtuple from dataclasses import dataclass, field from functools import partial -from operator import add, matmul, setitem +from operator import add, setitem from random import random from typing import NamedTuple @@ -96,7 +96,7 @@ def test_delayed(): def test_delayed_with_namedtuple(): class ANamedTuple(NamedTuple): - a: int + a: int # type: ignore[annotation-unchecked] literal = dask.delayed(3) with_class = dask.delayed({"a": ANamedTuple(a=literal)}) @@ -135,7 +135,7 @@ def return_nested(obj): def test_delayed_with_dataclass_with_custom_init(): @dataclass() class ADataClass: - a: int + a: int # type: ignore[annotation-unchecked] def __init__(self, b: int): self.a = b @@ -152,7 +152,7 @@ def __init__(self, b: int): def test_delayed_with_dataclass_with_eager_custom_init(): @dataclass() class ADataClass: - a: int + a: int # type: ignore[annotation-unchecked] def __init__(self, b: int): self.a = b @@ -170,8 +170,8 @@ def return_nested(obj): def test_delayed_with_eager_dataclass_with_set_init_false_field(): @dataclass class ADataClass: - a: int - b: int = field(init=False) + a: int # type: ignore[annotation-unchecked] + b: int = field(init=False) # type: ignore[annotation-unchecked] def prep_dataclass(a): data = ADataClass(a=a) @@ -191,8 +191,8 @@ def return_nested(obj): def test_delayed_with_dataclass_with_set_init_false_field(): @dataclass class ADataClass: - a: int - b: int = field(init=False) + a: int # type: ignore[annotation-unchecked] + b: int = field(init=False) # type: ignore[annotation-unchecked] literal = dask.delayed(3) @@ -211,8 +211,8 @@ def prep_dataclass(a): def test_delayed_with_dataclass_with_unset_init_false_field(): @dataclass class ADataClass: - a: int - b: int = field(init=False) + a: int # type: ignore[annotation-unchecked] + b: int = field(init=False) # type: ignore[annotation-unchecked] literal = dask.delayed(3) with_class = delayed({"data": ADataClass(a=literal)}) @@ -239,16 +239,13 @@ def test_operators(): assert (a > 2).compute() assert (a**2).compute() == 100 - if matmul: + class dummy: + def __matmul__(self, other): + return 4 - class dummy: - def __matmul__(self, other): - return 4 - - c = delayed(dummy()) # noqa - d = delayed(dummy()) # noqa - - assert (eval("c @ d")).compute() == 4 + c = delayed(dummy()) + d = delayed(dummy()) + assert (c @ d).compute() == 4 def test_methods(): diff --git a/dask/tests/test_typing.py b/dask/tests/test_typing.py index 9f7e58e6249..69a2c9c5b02 100644 --- a/dask/tests/test_typing.py +++ b/dask/tests/test_typing.py @@ -162,14 +162,10 @@ def assert_isinstance(coll: DaskCollection, protocol: Any) -> None: @pytest.mark.parametrize("protocol", [DaskCollection, HLGDaskCollection]) def test_isinstance_core(protocol): - from dask.array import Array - from dask.bag import Bag - from dask.dataframe import DataFrame - - arr: Array = da.ones(10) - bag: Bag = db.from_sequence([1, 2, 3, 4, 5], npartitions=2) - df: DataFrame = dds.timeseries() - dobj: Delayed = increment(2) + arr = da.ones(10) + bag = db.from_sequence([1, 2, 3, 4, 5], npartitions=2) + df = dds.timeseries() + dobj = increment(2) assert_isinstance(arr, protocol) assert_isinstance(bag, protocol)