Skip to content

Commit 2c032bd

Browse files
Merge branch 'main' into man-group/set-module-stringdtype
2 parents 996db1f + b434476 commit 2c032bd

File tree

21 files changed

+55
-48
lines changed

21 files changed

+55
-48
lines changed

doc/source/development/contributing_docstring.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ Finally, docstrings can also be appended to with the ``doc`` decorator.
940940

941941
In this example, we'll create a parent docstring normally (this is like
942942
``pandas.core.generic.NDFrame``). Then we'll have two children (like
943-
``pandas.core.series.Series`` and ``pandas.DataFrame``). We'll
943+
``pandas.Series`` and ``pandas.DataFrame``). We'll
944944
substitute the class names in this docstring.
945945

946946
.. code-block:: python
@@ -995,5 +995,5 @@ mapping function names to docstrings. Wherever possible, we prefer using
995995
``doc``, since the docstring-writing processes is slightly closer to normal.
996996

997997
See ``pandas.core.generic.NDFrame.fillna`` for an example template, and
998-
``pandas.core.series.Series.fillna`` and ``pandas.core.generic.frame.fillna``
998+
``pandas.Series.fillna`` and ``pandas.core.generic.frame.fillna``
999999
for the filled versions.

environment.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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/dtypes/dtypes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,9 +2130,11 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:
21302130
PerformanceWarning,
21312131
stacklevel=find_stack_level(),
21322132
)
2133-
21342133
np_dtypes = (x.subtype if isinstance(x, SparseDtype) else x for x in dtypes)
2135-
return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value)
2134+
# error: Argument 1 to "np_find_common_type" has incompatible type
2135+
# "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]";
2136+
# expected "dtype[Any]" [arg-type]
2137+
return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) # type: ignore [arg-type]
21362138

21372139

21382140
@register_extension_dtype

pandas/core/generic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8024,7 +8024,9 @@ 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+
# error: Unsupported operand type for
8028+
# ~ ("ExtensionArray | ndarray[Any, Any] | Any")
8029+
locs = self.index.asof_locs(where, ~nulls._values) # type: ignore[operator]
80288030

80298031
# mask the missing
80308032
mask = locs == -1

pandas/core/indexes/interval.py

Lines changed: 1 addition & 2 deletions
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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def iloc(self) -> _iLocIndexer:
212212
With a scalar integer.
213213
214214
>>> type(df.iloc[0])
215-
<class 'pandas.core.series.Series'>
215+
<class 'pandas.Series'>
216216
>>> df.iloc[0]
217217
a 1
218218
b 2
@@ -914,7 +914,9 @@ 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 = (
918+
cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc
919+
)
918920
iloc._setitem_with_indexer(indexer, value, self.name)
919921

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

pandas/core/missing.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,10 @@ 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+
# error: No overload variant of "apply_along_axis" matches
417+
# argument types "Callable[[ndarray[Any, Any]], None]",
418+
# "int", "ndarray[Any, Any]"
419+
np.apply_along_axis(func, axis, data) # type: ignore[call-overload]
423420

424421

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

pandas/core/nanops.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,9 @@ def nanmean(
726726

727727

728728
@bottleneck_switch()
729-
def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=None):
729+
def nanmedian(
730+
values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None
731+
) -> float | np.ndarray:
730732
"""
731733
Parameters
732734
----------
@@ -738,7 +740,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
738740
739741
Returns
740742
-------
741-
result : float
743+
result : float | ndarray
742744
Unless input is a float array, in which case use the same
743745
precision as the input array.
744746
@@ -758,7 +760,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
758760
# cases we never need to set NaN to the masked values
759761
using_nan_sentinel = values.dtype.kind == "f" and mask is None
760762

761-
def get_median(x, _mask=None):
763+
def get_median(x: np.ndarray, _mask=None):
762764
if _mask is None:
763765
_mask = notna(x)
764766
else:
@@ -794,6 +796,8 @@ def get_median(x, _mask=None):
794796

795797
notempty = values.size
796798

799+
res: float | np.ndarray
800+
797801
# an array from a frame
798802
if values.ndim > 1 and axis is not None:
799803
# there's a non-empty array to apply over otherwise numpy raises

pandas/core/series.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
Substitution,
5151
deprecate_nonkeyword_arguments,
5252
doc,
53+
set_module,
5354
)
5455
from pandas.util._validators import (
5556
validate_ascending,
@@ -229,6 +230,7 @@
229230
# error: Cannot override final attribute "size" (previously declared in base
230231
# class "NDFrame")
231232
# definition in base class "NDFrame"
233+
@set_module("pandas")
232234
class Series(base.IndexOpsMixin, NDFrame): # type: ignore[misc]
233235
"""
234236
One-dimensional ndarray with axis labels (including time series).

0 commit comments

Comments
 (0)