Skip to content

Commit 4cf63ea

Browse files
authored
DEPS: Bump cython 3.0 (#54335)
* DEPS: Bump Cython to 3.0 * DEPS: Bump Cython to 3.0 * fix stubtest :( * fix asvs? * why cython lint complain :( * Update typing
1 parent 4587c45 commit 4cf63ea

34 files changed

+66
-50
lines changed

asv_bench/asv.conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// pip (with all the conda available packages installed first,
4242
// followed by the pip installed packages).
4343
"matrix": {
44-
"Cython": ["0.29.33"],
44+
"Cython": ["3.0.0"],
4545
"matplotlib": [],
4646
"sqlalchemy": [],
4747
"scipy": [],

ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33
9+
- cython>=3.0.0
1010
- meson[ninja]=1.0.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-311-downstream_compat.yaml

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

88
# build dependencies
99
- versioneer[toml]
10-
- cython>=0.29.33
10+
- cython>=3.0.0
1111
- meson[ninja]=1.0.1
1212
- meson-python=0.13.1
1313

ci/deps/actions-311-pyarrownightly.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
# build dependencies
88
- versioneer[toml]
99
- meson[ninja]=1.0.1
10-
- cython>=0.29.33
10+
- cython>=3.0.0
1111
- meson-python=0.13.1
1212

1313
# test dependencies

ci/deps/actions-311.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33
9+
- cython>=3.0.0
1010
- meson[ninja]=1.0.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-39-minimum_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88

99
# build dependencies
1010
- versioneer[toml]
11-
- cython>=0.29.33
11+
- cython>=3.0.0
1212
- meson[ninja]=1.0.1
1313
- meson-python=0.13.1
1414

ci/deps/actions-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33
9+
- cython>=3.0.0
1010
- meson[ninja]=1.0.1
1111
- meson-python=0.13.1
1212

ci/deps/actions-pypy-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies:
99

1010
# build dependencies
1111
- versioneer[toml]
12-
- cython>=0.29.33
12+
- cython>=3.0.0
1313
- meson[ninja]=1.0.1
1414
- meson-python=0.13.1
1515

ci/deps/circle-310-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66

77
# build dependencies
88
- versioneer[toml]
9-
- cython>=0.29.33
9+
- cython>=3.0.0
1010
- meson[ninja]=1.0.1
1111
- meson-python=0.13.1
1212

doc/source/whatsnew/v2.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ Other
847847
- Bug in :meth:`Series.memory_usage` when ``deep=True`` throw an error with Series of objects and the returned value is incorrect, as it does not take into account GC corrections (:issue:`51858`)
848848
- Bug in :meth:`period_range` the default behavior when freq was not passed as an argument was incorrect(:issue:`53687`)
849849
- Fixed incorrect ``__name__`` attribute of ``pandas._libs.json`` (:issue:`52898`)
850+
- The minimum version of Cython needed to compile pandas is now ``3.0.0`` (:issue:`54335`)
850851

851852
.. ***DO NOT USE THIS SECTION***
852853

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88

99
# build dependencies
1010
- versioneer[toml]
11-
- cython=0.29.33
11+
- cython=3.0.0
1212
- meson[ninja]=1.0.1
1313
- meson-python=0.13.1
1414

pandas/_libs/arrays.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NDArrayBacked:
2626
def size(self) -> int: ...
2727
@property
2828
def nbytes(self) -> int: ...
29-
def copy(self): ...
29+
def copy(self, order=...): ...
3030
def delete(self, loc, axis=...): ...
3131
def swapaxes(self, axis1, axis2): ...
3232
def repeat(self, repeats: int | Sequence[int], axis: int | None = ...): ...

pandas/_libs/groupby.pyi

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def group_fillna_indexer(
4444
labels: np.ndarray, # ndarray[int64_t]
4545
sorted_labels: npt.NDArray[np.intp],
4646
mask: npt.NDArray[np.uint8],
47-
direction: Literal["ffill", "bfill"],
4847
limit: int, # int64_t
4948
dropna: bool,
5049
) -> None: ...
@@ -55,7 +54,7 @@ def group_any_all(
5554
mask: np.ndarray, # const uint8_t[::1]
5655
val_test: Literal["any", "all"],
5756
skipna: bool,
58-
nullable: bool,
57+
result_mask: np.ndarray | None,
5958
) -> None: ...
6059
def group_sum(
6160
out: np.ndarray, # complexfloatingintuint_t[:, ::1]

pandas/_libs/hashtable.pyi

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Factorizer:
2020
def factorize(
2121
self,
2222
values: np.ndarray,
23-
sort: bool = ...,
2423
na_sentinel=...,
2524
na_value=...,
2625
mask=...,
@@ -157,9 +156,9 @@ class HashTable:
157156
def __contains__(self, key: Hashable) -> bool: ...
158157
def sizeof(self, deep: bool = ...) -> int: ...
159158
def get_state(self) -> dict[str, int]: ...
160-
# TODO: `item` type is subclass-specific
161-
def get_item(self, item): ... # TODO: return type?
162-
def set_item(self, item, val) -> None: ...
159+
# TODO: `val/key` type is subclass-specific
160+
def get_item(self, val): ... # TODO: return type?
161+
def set_item(self, key, val) -> None: ...
163162
def get_na(self): ... # TODO: return type?
164163
def set_na(self, val) -> None: ...
165164
def map_locations(
@@ -185,6 +184,7 @@ class HashTable:
185184
self,
186185
values: np.ndarray, # np.ndarray[subclass-specific]
187186
return_inverse: bool = ...,
187+
mask=...,
188188
) -> (
189189
tuple[
190190
np.ndarray, # np.ndarray[subclass-specific]
@@ -198,6 +198,7 @@ class HashTable:
198198
na_sentinel: int = ...,
199199
na_value: object = ...,
200200
mask=...,
201+
ignore_na: bool = True,
201202
) -> tuple[np.ndarray, npt.NDArray[np.intp]]: ... # np.ndarray[subclass-specific]
202203

203204
class Complex128HashTable(HashTable): ...

pandas/_libs/hashtable_class_helper.pxi.in

+4-2
Original file line numberDiff line numberDiff line change
@@ -1239,9 +1239,10 @@ cdef class StringHashTable(HashTable):
12391239
na_value=na_value, ignore_na=ignore_na,
12401240
return_inverse=True)
12411241

1242+
# Add unused mask parameter for compat with other signatures
12421243
def get_labels(self, ndarray[object] values, ObjectVector uniques,
12431244
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
1244-
object na_value=None):
1245+
object na_value=None, object mask=None):
12451246
# -> np.ndarray[np.intp]
12461247
_, labels = self._unique(values, uniques, count_prior=count_prior,
12471248
na_sentinel=na_sentinel, na_value=na_value,
@@ -1496,9 +1497,10 @@ cdef class PyObjectHashTable(HashTable):
14961497
na_value=na_value, ignore_na=ignore_na,
14971498
return_inverse=True)
14981499

1500+
# Add unused mask parameter for compat with other signatures
14991501
def get_labels(self, ndarray[object] values, ObjectVector uniques,
15001502
Py_ssize_t count_prior=0, Py_ssize_t na_sentinel=-1,
1501-
object na_value=None):
1503+
object na_value=None, object mask=None):
15021504
# -> np.ndarray[np.intp]
15031505
_, labels = self._unique(values, uniques, count_prior=count_prior,
15041506
na_sentinel=na_sentinel, na_value=na_value,

pandas/_libs/lib.pyi

+12-10
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,24 @@ def is_scalar(val: object) -> bool: ...
4444
def is_list_like(obj: object, allow_sets: bool = ...) -> bool: ...
4545
def is_pyarrow_array(obj: object) -> bool: ...
4646
def is_period(val: object) -> TypeGuard[Period]: ...
47-
def is_interval(val: object) -> TypeGuard[Interval]: ...
48-
def is_decimal(val: object) -> TypeGuard[Decimal]: ...
49-
def is_complex(val: object) -> TypeGuard[complex]: ...
50-
def is_bool(val: object) -> TypeGuard[bool | np.bool_]: ...
51-
def is_integer(val: object) -> TypeGuard[int | np.integer]: ...
47+
def is_interval(obj: object) -> TypeGuard[Interval]: ...
48+
def is_decimal(obj: object) -> TypeGuard[Decimal]: ...
49+
def is_complex(obj: object) -> TypeGuard[complex]: ...
50+
def is_bool(obj: object) -> TypeGuard[bool | np.bool_]: ...
51+
def is_integer(obj: object) -> TypeGuard[int | np.integer]: ...
5252
def is_int_or_none(obj) -> bool: ...
53-
def is_float(val: object) -> TypeGuard[float]: ...
53+
def is_float(obj: object) -> TypeGuard[float]: ...
5454
def is_interval_array(values: np.ndarray) -> bool: ...
55-
def is_datetime64_array(values: np.ndarray) -> bool: ...
56-
def is_timedelta_or_timedelta64_array(values: np.ndarray) -> bool: ...
55+
def is_datetime64_array(values: np.ndarray, skipna: bool = True) -> bool: ...
56+
def is_timedelta_or_timedelta64_array(
57+
values: np.ndarray, skipna: bool = True
58+
) -> bool: ...
5759
def is_datetime_with_singletz_array(values: np.ndarray) -> bool: ...
5860
def is_time_array(values: np.ndarray, skipna: bool = ...): ...
5961
def is_date_array(values: np.ndarray, skipna: bool = ...): ...
6062
def is_datetime_array(values: np.ndarray, skipna: bool = ...): ...
6163
def is_string_array(values: np.ndarray, skipna: bool = ...): ...
62-
def is_float_array(values: np.ndarray, skipna: bool = ...): ...
64+
def is_float_array(values: np.ndarray): ...
6365
def is_integer_array(values: np.ndarray, skipna: bool = ...): ...
6466
def is_bool_array(values: np.ndarray, skipna: bool = ...): ...
6567
def fast_multiget(mapping: dict, keys: np.ndarray, default=...) -> np.ndarray: ...
@@ -180,7 +182,7 @@ def count_level_2d(
180182
max_bin: int,
181183
) -> np.ndarray: ... # np.ndarray[np.int64, ndim=2]
182184
def get_level_sorter(
183-
label: np.ndarray, # const int64_t[:]
185+
codes: np.ndarray, # const int64_t[:]
184186
starts: np.ndarray, # const intp_t[:]
185187
) -> np.ndarray: ... # np.ndarray[np.intp, ndim=1]
186188
def generate_bins_dt64(

pandas/_libs/ops.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def vec_binop(
3636
@overload
3737
def maybe_convert_bool(
3838
arr: npt.NDArray[np.object_],
39-
true_values: Iterable = ...,
40-
false_values: Iterable = ...,
39+
true_values: Iterable | None = None,
40+
false_values: Iterable | None = None,
4141
convert_to_masked_nullable: Literal[False] = ...,
4242
) -> tuple[np.ndarray, None]: ...
4343
@overload

pandas/_libs/sparse.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class BlockIndex(SparseIndex):
3939
self, length: int, blocs: np.ndarray, blengths: np.ndarray
4040
) -> None: ...
4141

42+
# Override to have correct parameters
43+
def intersect(self, other: SparseIndex) -> Self: ...
44+
def make_union(self, y: SparseIndex) -> Self: ...
45+
4246
def make_mask_object_ndarray(
4347
arr: npt.NDArray[np.object_], fill_value
4448
) -> npt.NDArray[np.bool_]: ...

pandas/_libs/tslibs/conversion.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ TD64NS_DTYPE: np.dtype
1010

1111
def precision_from_unit(
1212
unit: str,
13+
out_reso: int = ...,
1314
) -> tuple[int, int]: ... # (int64_t, _)
1415
def localize_pydatetime(dt: datetime, tz: tzinfo | None) -> datetime: ...

pandas/_libs/tslibs/dtypes.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ from enum import Enum
55
_attrname_to_abbrevs: dict[str, str]
66
_period_code_map: dict[str, int]
77

8-
def periods_per_day(reso: int) -> int: ...
8+
def periods_per_day(reso: int = ...) -> int: ...
99
def periods_per_second(reso: int) -> int: ...
1010
def is_supported_unit(reso: int) -> bool: ...
11-
def npy_unit_to_abbrev(reso: int) -> str: ...
11+
def npy_unit_to_abbrev(unit: int) -> str: ...
1212
def get_supported_reso(reso: int) -> int: ...
1313
def abbrev_to_npy_unit(abbrev: str) -> int: ...
1414

pandas/_libs/tslibs/np_datetime.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class OutOfBoundsTimedelta(ValueError): ...
99
def py_get_unit_from_dtype(dtype: np.dtype): ...
1010
def py_td64_to_tdstruct(td64: int, unit: int) -> dict: ...
1111
def astype_overflowsafe(
12-
arr: np.ndarray,
12+
values: np.ndarray,
1313
dtype: np.dtype,
1414
copy: bool = ...,
1515
round_ok: bool = ...,

pandas/_libs/tslibs/offsets.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ def roll_qtrday(
275275
INVALID_FREQ_ERR_MSG: Literal["Invalid frequency: {0}"]
276276

277277
def shift_months(
278-
dtindex: npt.NDArray[np.int64], months: int, day_opt: str | None = ...
278+
dtindex: npt.NDArray[np.int64],
279+
months: int,
280+
day_opt: str | None = ...,
281+
reso: int = ...,
279282
) -> npt.NDArray[np.int64]: ...
280283

281284
_offset_map: dict[str, BaseOffset]

pandas/_libs/tslibs/period.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Period(PeriodMixin):
8989
@classmethod
9090
def _from_ordinal(cls, ordinal: int, freq) -> Period: ...
9191
@classmethod
92-
def now(cls, freq: BaseOffset = ...) -> Period: ...
92+
def now(cls, freq: BaseOffset) -> Period: ...
9393
def strftime(self, fmt: str) -> str: ...
9494
def to_timestamp(
9595
self,

pandas/_libs/tslibs/period.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ cdef class _Period(PeriodMixin):
25112511
object_state = None, self.freq, self.ordinal
25122512
return (Period, object_state)
25132513

2514-
def strftime(self, fmt: str) -> str:
2514+
def strftime(self, fmt: str | None) -> str:
25152515
r"""
25162516
Returns a formatted string representation of the :class:`Period`.
25172517

pandas/_libs/tslibs/timedeltas.pyi

+5-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ UnitChoices = Literal[
6767
_S = TypeVar("_S", bound=timedelta)
6868

6969
def ints_to_pytimedelta(
70-
arr: npt.NDArray[np.timedelta64],
70+
m8values: npt.NDArray[np.timedelta64],
7171
box: bool = ...,
7272
) -> npt.NDArray[np.object_]: ...
7373
def array_to_timedelta64(
@@ -161,8 +161,10 @@ class Timedelta(timedelta):
161161
def __gt__(self, other: timedelta) -> bool: ...
162162
def __hash__(self) -> int: ...
163163
def isoformat(self) -> str: ...
164-
def to_numpy(self) -> np.timedelta64: ...
165-
def view(self, dtype: npt.DTypeLike = ...) -> object: ...
164+
def to_numpy(
165+
self, dtype: npt.DTypeLike = ..., copy: bool = False
166+
) -> np.timedelta64: ...
167+
def view(self, dtype: npt.DTypeLike) -> object: ...
166168
@property
167169
def unit(self) -> str: ...
168170
def as_unit(self, unit: str, round_ok: bool = ...) -> Timedelta: ...

pandas/_libs/tslibs/timestamps.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Timestamp(datetime):
177177
def is_year_end(self) -> bool: ...
178178
def to_pydatetime(self, warn: bool = ...) -> datetime: ...
179179
def to_datetime64(self) -> np.datetime64: ...
180-
def to_period(self, freq: BaseOffset | str = ...) -> Period: ...
180+
def to_period(self, freq: BaseOffset | str | None = None) -> Period: ...
181181
def to_julian_date(self) -> np.float64: ...
182182
@property
183183
def asm8(self) -> np.datetime64: ...

pandas/_libs/tslibs/tzconversion.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from pandas._typing import npt
1010

1111
# tz_convert_from_utc_single exposed for testing
1212
def tz_convert_from_utc_single(
13-
val: np.int64, tz: tzinfo, creso: int = ...
13+
utc_val: np.int64, tz: tzinfo, creso: int = ...
1414
) -> np.int64: ...
1515
def tz_localize_to_utc(
1616
vals: npt.NDArray[np.int64],

pandas/_libs/tslibs/vectorized.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_resolution(
3131
reso: int = ..., # NPY_DATETIMEUNIT
3232
) -> Resolution: ...
3333
def ints_to_pydatetime(
34-
arr: npt.NDArray[np.int64],
34+
stamps: npt.NDArray[np.int64],
3535
tz: tzinfo | None = ...,
3636
box: str = ...,
3737
reso: int = ..., # NPY_DATETIMEUNIT

pandas/_libs/window/aggregations.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def ewm(
111111
com: float, # float64_t
112112
adjust: bool,
113113
ignore_na: bool,
114-
deltas: np.ndarray, # const float64_t[:]
115-
normalize: bool,
114+
deltas: np.ndarray | None = None, # const float64_t[:]
115+
normalize: bool = True,
116116
) -> np.ndarray: ... # np.ndarray[np.float64]
117117
def ewmcov(
118118
input_x: np.ndarray, # const float64_t[:]

pandas/core/arrays/datetimelike.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2255,8 +2255,7 @@ def _concat_same_type(
22552255
return new_obj
22562256

22572257
def copy(self, order: str = "C") -> Self:
2258-
# error: Unexpected keyword argument "order" for "copy"
2259-
new_obj = super().copy(order=order) # type: ignore[call-arg]
2258+
new_obj = super().copy(order=order)
22602259
new_obj._freq = self.freq
22612260
return new_obj
22622261

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = [
55
"meson-python==0.13.1",
66
"meson==1.0.1",
77
"wheel",
8-
"Cython>=0.29.33,<3", # Note: sync with setup.py, environment.yml and asv.conf.json
8+
"Cython>=3.0.0", # Note: sync with setup.py, environment.yml and asv.conf.json
99
# Note: numpy 1.25 has a backwards compatible C API by default
1010
# we don't want to force users to compile with 1.25 though
1111
# (Ideally, in the future, though, oldest-supported-numpy can be dropped when our min numpy is 1.25.x)

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
pip
55
versioneer[toml]
6-
cython==0.29.33
6+
cython==3.0.0
77
meson[ninja]==1.0.1
88
meson-python==0.13.1
99
pytest>=7.3.2

0 commit comments

Comments
 (0)