Skip to content

Commit

Permalink
Bump mypy version (#9697)
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Nov 25, 2022
1 parent 07c57d8 commit 3ac3b8d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 61 deletions.
33 changes: 4 additions & 29 deletions .pre-commit-config.yaml
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions dask/dataframe/core.py
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions dask/dataframe/io/tests/test_parquet.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dask/tests/test_base.py
Expand Up @@ -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
Expand Down
35 changes: 16 additions & 19 deletions dask/tests/test_delayed.py
Expand Up @@ -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

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

Expand All @@ -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)})
Expand All @@ -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():
Expand Down
12 changes: 4 additions & 8 deletions dask/tests/test_typing.py
Expand Up @@ -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)
Expand Down

0 comments on commit 3ac3b8d

Please sign in to comment.