Skip to content

Commit bcff1ae

Browse files
committed
Merge branch 'update_mypy' into fix_column_typeerror
2 parents a36a34e + 500f006 commit bcff1ae

File tree

11 files changed

+15
-29
lines changed

11 files changed

+15
-29
lines changed

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dependencies:
7777

7878
# code checks
7979
- flake8=7.1.0 # run in subprocess over docstring examples
80-
- mypy=1.11.2 # pre-commit uses locally installed mypy
80+
- mypy=1.13.0 # pre-commit uses locally installed mypy
8181
- tokenize-rt # scripts/check_for_inconsistent_pandas_namespace.py
8282
- pre-commit>=4.0.1
8383

pandas/core/computation/ops.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
class Term:
7777
def __new__(cls, name, env, side=None, encoding=None):
7878
klass = Constant if not isinstance(name, str) else cls
79-
# error: Argument 2 for "super" not an instance of argument 1
80-
supr_new = super(Term, klass).__new__ # type: ignore[misc]
79+
supr_new = super(Term, klass).__new__
8180
return supr_new(klass)
8281

8382
is_local: bool

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8024,7 +8024,7 @@ def asof(self, where, subset=None):
80248024
np.nan, index=self.columns, name=where[0]
80258025
)
80268026

8027-
locs = self.index.asof_locs(where, ~(nulls._values))
8027+
locs = self.index.asof_locs(where, ~cast("DataFrame", nulls._values))
80288028

80298029
# mask the missing
80308030
mask = locs == -1

pandas/core/indexes/interval.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,7 @@ def _maybe_convert_i8(self, key):
558558
left = self._maybe_convert_i8(key.left)
559559
right = self._maybe_convert_i8(key.right)
560560
constructor = Interval if scalar else IntervalIndex.from_arrays
561-
# error: "object" not callable
562-
return constructor(left, right, closed=self.closed) # type: ignore[operator]
561+
return constructor(left, right, closed=self.closed)
563562

564563
if scalar:
565564
# Timestamp/Timedelta

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def __setitem__(self, key, value) -> None:
914914
indexer = self._get_setitem_indexer(key)
915915
self._has_valid_setitem_indexer(key)
916916

917-
iloc = self if self.name == "iloc" else self.obj.iloc
917+
iloc: _iLocIndexer = cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc
918918
iloc._setitem_with_indexer(indexer, value, self.name)
919919

920920
def _validate_key(self, key, axis: AxisInt) -> None:

pandas/core/missing.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,7 @@ def func(yvalues: np.ndarray) -> None:
413413
**kwargs,
414414
)
415415

416-
# error: Argument 1 to "apply_along_axis" has incompatible type
417-
# "Callable[[ndarray[Any, Any]], None]"; expected "Callable[...,
418-
# Union[_SupportsArray[dtype[<nothing>]], Sequence[_SupportsArray
419-
# [dtype[<nothing>]]], Sequence[Sequence[_SupportsArray[dtype[<nothing>]]]],
420-
# Sequence[Sequence[Sequence[_SupportsArray[dtype[<nothing>]]]]],
421-
# Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[<nothing>]]]]]]]]"
422-
np.apply_along_axis(func, axis, data) # type: ignore[arg-type]
416+
np.apply_along_axis(func, axis, data)
423417

424418

425419
def _index_to_interp_indices(index: Index, method: str) -> np.ndarray:

pandas/core/nanops.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def nanmean(
726726

727727

728728
@bottleneck_switch()
729-
def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=None):
729+
def nanmedian(values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None) -> float | np.ndarray:
730730
"""
731731
Parameters
732732
----------
@@ -738,7 +738,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
738738
739739
Returns
740740
-------
741-
result : float
741+
result : float | ndarray
742742
Unless input is a float array, in which case use the same
743743
precision as the input array.
744744
@@ -758,7 +758,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
758758
# cases we never need to set NaN to the masked values
759759
using_nan_sentinel = values.dtype.kind == "f" and mask is None
760760

761-
def get_median(x, _mask=None):
761+
def get_median(x: np.ndarray, _mask=None):
762762
if _mask is None:
763763
_mask = notna(x)
764764
else:
@@ -794,6 +794,8 @@ def get_median(x, _mask=None):
794794

795795
notempty = values.size
796796

797+
res: float | np.ndarray
798+
797799
# an array from a frame
798800
if values.ndim > 1 and axis is not None:
799801
# there's a non-empty array to apply over otherwise numpy raises

pandas/io/common.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,8 @@ def get_handle(
910910
or not hasattr(handle, "seekable")
911911
):
912912
handle = _IOWrapper(handle)
913-
# error: Argument 1 to "TextIOWrapper" has incompatible type
914-
# "_IOWrapper"; expected "IO[bytes]"
915913
handle = TextIOWrapper(
916-
handle, # type: ignore[arg-type]
914+
handle,
917915
encoding=ioargs.encoding,
918916
errors=errors,
919917
newline="",

pandas/plotting/_matplotlib/boxplot.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,7 @@ def _make_plot(self, fig: Figure) -> None:
198198
else self.data
199199
)
200200

201-
# error: Argument "data" to "_iter_data" of "MPLPlot" has
202-
# incompatible type "object"; expected "DataFrame |
203-
# dict[Hashable, Series | DataFrame]"
204-
for i, (label, y) in enumerate(self._iter_data(data=data)): # type: ignore[arg-type]
201+
for i, (label, y) in enumerate(self._iter_data(data=data)):
205202
ax = self._get_ax(i)
206203
kwds = self.kwds.copy()
207204

pandas/plotting/_matplotlib/hist.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ def _make_plot(self, fig: Figure) -> None:
137137
if self.by is not None
138138
else self.data
139139
)
140-
141-
# error: Argument "data" to "_iter_data" of "MPLPlot" has incompatible
142-
# type "object"; expected "DataFrame | dict[Hashable, Series | DataFrame]"
143-
for i, (label, y) in enumerate(self._iter_data(data=data)): # type: ignore[arg-type]
140+
for i, (label, y) in enumerate(self._iter_data(data=data)):
144141
ax = self._get_ax(i)
145142

146143
kwds = self.kwds.copy()

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ moto
5454
flask
5555
asv>=0.6.1
5656
flake8==7.1.0
57-
mypy==1.11.2
57+
mypy==1.13.0
5858
tokenize-rt
5959
pre-commit>=4.0.1
6060
gitpython

0 commit comments

Comments
 (0)