Skip to content

Commit b30af16

Browse files
committed
mypy fixes, add mypy pre-commit hook
1 parent 343a87f commit b30af16

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ repos:
2020
rev: 3.9.2
2121
hooks:
2222
- id: flake8
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v0.961
25+
hooks:
26+
- id: mypy

tests/api.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ def get_chunks(self, n_chunks: int | None = None) -> Iterable[Column]:
242242
See `DataFrame.get_chunks` for details on ``n_chunks``.
243243
"""
244244

245-
def get_buffers(
246-
self,
247-
) -> dict[tuple[Buffer, Any], tuple[Buffer, Any] | None, tuple[Buffer, Any] | None]:
245+
def get_buffers(self) -> dict[str, Any]:
248246
"""
249247
Return a dictionary containing the underlying buffers.
250248

tests/test_signatures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from inspect import Parameter, getmembers, isfunction, signature
22
from types import FunctionType
3-
from typing import Callable
3+
from typing import Callable # See https://github.com/python/mypy/issues/6864
44

55
import pytest
66
from hypothesis import assume, given, note, settings
@@ -75,7 +75,7 @@ def _test_signature(func, stub):
7575
def test_toplevel_dataframe_dunder_dataframe(libinfo: LibraryInfo, data: st.DataObject):
7676
df = data.draw(libinfo.toplevel_dataframes(), label="df")
7777
assert hasattr(df, "__dataframe__")
78-
assert isinstance(df.__dataframe__, Callable)
78+
assert isinstance(df.__dataframe__, Callable) # type: ignore
7979
_test_signature(df.__dataframe__, DataFrame.__dataframe__)
8080

8181

@@ -94,7 +94,7 @@ def test_dataframe_method(
9494
df = data.draw(libinfo.compliant_dataframes(), label="df")
9595
assert hasattr(df, stub.__name__)
9696
method = getattr(df, stub.__name__)
97-
assert isinstance(method, Callable)
97+
assert isinstance(method, Callable) # type: ignore
9898
_test_signature(method, stub)
9999

100100

@@ -114,7 +114,7 @@ def test_column_method(libinfo: LibraryInfo, stub: FunctionType, data: st.DataOb
114114
note(f"{col=}")
115115
assert hasattr(col, stub.__name__)
116116
method = getattr(col, stub.__name__)
117-
assert isinstance(method, Callable)
117+
assert isinstance(method, Callable) # type: ignore
118118
_test_signature(method, stub)
119119

120120

@@ -137,5 +137,5 @@ def test_buffer_method(libinfo: LibraryInfo, stub: FunctionType, data: st.DataOb
137137
note(f"{buf=}")
138138
assert hasattr(buf, stub.__name__)
139139
method = getattr(buf, stub.__name__)
140-
assert isinstance(method, Callable)
140+
assert isinstance(method, Callable) # type: ignore
141141
_test_signature(method, stub)

tests/wrappers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,5 @@ def cudf_mock_to_toplevel(mock_df: MockDataFrame) -> cudf.DataFrame:
301301
for param in libinfo_params:
302302
if not any(m.name.startswith("skip") for m in param.marks):
303303
libinfo = param.values[0]
304+
assert isinstance(libinfo, LibraryInfo) # for mypy
304305
libname_to_libinfo[libinfo.name] = libinfo

0 commit comments

Comments
 (0)