Skip to content
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

Update to mypy 0.971 #11640

Merged
merged 10 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 13 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ repos:
files: python/.*\.(py|pyx|pxd)$
types: [file]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.782'
rev: 'v0.971'
hooks:
- id: mypy
args: ["--config-file=setup.cfg", "python/cudf/cudf", "python/dask_cudf/dask_cudf", "python/custreamz/custreamz", "python/cudf_kafka/cudf_kafka"]
additional_dependencies: [types-cachetools==5.2.1]
wence- marked this conversation as resolved.
Show resolved Hide resolved
args: ["--config-file=setup.cfg",
"--exclude", "python/cudf/benchmarks",
wence- marked this conversation as resolved.
Show resolved Hide resolved
"--exclude", "python/cudf/cudf/tests",
"--exclude", "python/dask_cudf/dask_cudf/tests",
"--exclude", "python/custreamz/custreamz/tests",
"--exclude", "python/cudf_kafka/cudf_kafka/tests",
"--exclude", "python/cudf/cudf/_lib",
"python/cudf/cudf",
"python/dask_cudf/dask_cudf",
"python/custreamz/custreamz",
"python/cudf_kafka/cudf_kafka"]
pass_filenames: false
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
Expand Down
7 changes: 6 additions & 1 deletion python/cudf/cudf/core/column/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,12 @@ def isempty(self) -> SeriesOrIndex:
4 False
dtype: bool
"""
return self._return_or_inplace((self._column == "").fillna(False))
return self._return_or_inplace(
# mypy can't deduce that the return value of
wence- marked this conversation as resolved.
Show resolved Hide resolved
# StringColumn.__eq__ is ColumnBase because the binops are
# dynamically added by a mixin class
(self._column == "").fillna(False) # type: ignore
)

def isspace(self) -> SeriesOrIndex:
r"""
Expand Down
8 changes: 6 additions & 2 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
Optional,
Set,
Tuple,
Type,
TypeVar,
Union,
)
Expand Down Expand Up @@ -104,6 +103,11 @@
_external_only_api,
)

if sys.version_info < (3, 10):
wence- marked this conversation as resolved.
Show resolved Hide resolved
NotImplementedType = Any
wence- marked this conversation as resolved.
Show resolved Hide resolved
else:
from types import NotImplementedType

T = TypeVar("T", bound="DataFrame")


Expand Down Expand Up @@ -1934,7 +1938,7 @@ def _make_operands_and_index_for_binop(
) -> Tuple[
Union[
Dict[Optional[str], Tuple[ColumnBase, Any, bool, Any]],
Type[NotImplemented],
NotImplementedType,
],
Optional[BaseIndex],
]:
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def step(self):
def _num_rows(self):
return len(self)

@cached_property
@cached_property # type: ignore
wence- marked this conversation as resolved.
Show resolved Hide resolved
@_cudf_nvtx_annotate
def _values(self):
if len(self) > 0:
Expand Down
3 changes: 2 additions & 1 deletion python/cudf/cudf/core/indexed_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import warnings
from collections import Counter, abc
from functools import cached_property
from types import NotImplementedType
wence- marked this conversation as resolved.
Show resolved Hide resolved
from typing import (
Any,
Callable,
Expand Down Expand Up @@ -2991,7 +2992,7 @@ def _make_operands_and_index_for_binop(
) -> Tuple[
Union[
Dict[Optional[str], Tuple[ColumnBase, Any, bool, Any]],
Type[NotImplemented],
NotImplementedType,
],
Optional[cudf.BaseIndex],
]:
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ def from_pandas(cls, multiindex, nan_as_null=None):
)
return cls.from_frame(df, names=multiindex.names)

@cached_property
@cached_property # type: ignore
@_cudf_nvtx_annotate
def is_unique(self):
wence- marked this conversation as resolved.
Show resolved Hide resolved
return len(self) == len(self.unique())
Expand Down
5 changes: 3 additions & 2 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import textwrap
from collections import abc
from shutil import get_terminal_size
from typing import Any, Dict, MutableMapping, Optional, Set, Tuple, Type, Union
from types import NotImplementedType
from typing import Any, Dict, MutableMapping, Optional, Set, Tuple, Union

import cupy
import numpy as np
Expand Down Expand Up @@ -1289,7 +1290,7 @@ def _make_operands_and_index_for_binop(
) -> Tuple[
Union[
Dict[Optional[str], Tuple[ColumnBase, Any, bool, Any]],
Type[NotImplemented],
NotImplementedType,
],
Optional[BaseIndex],
]:
Expand Down
11 changes: 9 additions & 2 deletions python/cudf/cudf/core/single_column_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from __future__ import annotations

import sys
import warnings
from typing import Any, Dict, Optional, Tuple, Type, TypeVar, Union
from typing import Any, Dict, Optional, Tuple, TypeVar, Union

import cupy
import numpy as np
Expand All @@ -21,6 +22,12 @@
from cudf.core.frame import Frame
from cudf.utils.utils import NotIterable, _cudf_nvtx_annotate

if sys.version_info < (3, 10):
NotImplementedType = Any
else:
from types import NotImplementedType


T = TypeVar("T", bound="Frame")


Expand Down Expand Up @@ -302,7 +309,7 @@ def _make_operands_for_binop(
**kwargs,
) -> Union[
Dict[Optional[str], Tuple[ColumnBase, Any, bool, Any]],
Type[NotImplemented],
NotImplementedType,
]:
"""Generate the dictionary of operands used for a binary operation.

Expand Down
15 changes: 0 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,17 @@ select =
[mypy]
ignore_missing_imports = True

[mypy-cudf._lib.*]
wence- marked this conversation as resolved.
Show resolved Hide resolved
ignore_errors = True

[mypy-cudf._version]
ignore_errors = True

[mypy-cudf.utils.metadata.orc_column_statistics_pb2]
ignore_errors = True

[mypy-cudf.tests.*]
ignore_errors = True

[mypy-dask_cudf._version]
ignore_errors = True

[mypy-dask_cudf.tests.*]
ignore_errors = True

[mypy-custreamz._version]
ignore_errors = True

[mypy-custreamz.tests.*]
ignore_errors = True

[mypy-cudf_kafka._version]
ignore_errors = True

[mypy-cudf_kafka.tests.*]
wence- marked this conversation as resolved.
Show resolved Hide resolved
ignore_errors = True