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 6 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
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ 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",
"python/cudf/cudf",
"python/custreamz/custreamz",
"python/cudf_kafka/cudf_kafka",
"python/dask_cudf/dask_cudf"]
pass_filenames: false
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
Expand Down
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda11.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ dependencies:
- flake8=3.8.3
- black=22.3.0
- isort=5.10.1
- mypy=0.782
- mypy=0.971
- types-cachetools==5.2.1
wence- marked this conversation as resolved.
Show resolved Hide resolved
- doxygen=1.8.20
- pydocstyle=6.1.1
- typing_extensions
Expand Down
8 changes: 7 additions & 1 deletion python/cudf/cudf/core/column/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
from cudf.core.buffer import DeviceBufferLike
from cudf.core.column import column, datetime
from cudf.core.column.column import ColumnBase
from cudf.core.column.methods import ColumnMethods
from cudf.utils.docutils import copy_docstring
from cudf.utils.dtypes import can_convert_to_column
Expand Down Expand Up @@ -3650,7 +3651,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
cast(ColumnBase, self._column == "").fillna(False)
)

def isspace(self) -> SeriesOrIndex:
r"""
Expand Down
10 changes: 8 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,13 @@
_external_only_api,
)

if sys.version_info >= (3, 10):
# Introduced in Python 3.10
from types import NotImplementedType
else:
NotImplementedType = Any
wence- marked this conversation as resolved.
Show resolved Hide resolved


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


Expand Down Expand Up @@ -1934,7 +1940,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
10 changes: 9 additions & 1 deletion python/cudf/cudf/core/indexed_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numbers
import operator
import sys
import textwrap
import warnings
from collections import Counter, abc
Expand Down Expand Up @@ -55,6 +56,13 @@
from cudf.utils import docutils
from cudf.utils.utils import _cudf_nvtx_annotate

if sys.version_info >= (3, 10):
# Introduced in Python 3.10
from types import NotImplementedType
else:
NotImplementedType = Any
wence- marked this conversation as resolved.
Show resolved Hide resolved


doc_reset_index_template = """
Reset the index of the {klass}, or a level of it.

Expand Down Expand Up @@ -2991,7 +2999,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
11 changes: 9 additions & 2 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import functools
import inspect
import pickle
import sys
import textwrap
from collections import abc
from shutil import get_terminal_size
from typing import Any, Dict, MutableMapping, Optional, Set, Tuple, Type, Union
from typing import Any, Dict, MutableMapping, Optional, Set, Tuple, Union

import cupy
import numpy as np
Expand Down Expand Up @@ -74,6 +75,12 @@
)
from cudf.utils.utils import _cudf_nvtx_annotate

if sys.version_info >= (3, 10):
# Introduced in Python 3.10
from types import NotImplementedType
else:
NotImplementedType = Any


def _format_percentile_names(percentiles):
return [f"{int(x * 100)}%" for x in percentiles]
Expand Down Expand Up @@ -1289,7 +1296,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
12 changes: 10 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,13 @@
from cudf.core.frame import Frame
from cudf.utils.utils import NotIterable, _cudf_nvtx_annotate

if sys.version_info >= (3, 10):
# Introduced in Python 3.10
from types import NotImplementedType
else:
NotImplementedType = Any


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


Expand Down Expand Up @@ -302,7 +310,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
42 changes: 12 additions & 30 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,15 @@ 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
# If we don't specify this, then mypy will check excluded files if
# they are imported by an checked file.
wence- marked this conversation as resolved.
Show resolved Hide resolved
follow_imports = skip
exclude = (?x)(
(cudf|custreamz|cudf_kafka|dask_cudf)/_version\.py
| cudf/_lib/
| cudf/cudf/benchmarks/
| cudf/cudf/tests/
| custreamz/custreamz/tests/
| dask_cudf/dask_cudf/tests/
# This close paren cannot be in column zero otherwise the config parser barfs
wence- marked this conversation as resolved.
Show resolved Hide resolved
)