Skip to content

Conversation

@loicdiridollou
Copy link
Member

@loicdiridollou loicdiridollou commented Dec 18, 2025

  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added (Please use assert_type() to assert the type of any return value)
  • If I used AI to develop this pull request, I prompted it to follow AGENTS.md.

Quite a bit of clean up to comply with ANN rules.

@loicdiridollou loicdiridollou marked this pull request as draft December 18, 2025 19:09
@loicdiridollou loicdiridollou marked this pull request as ready for review December 18, 2025 19:16
Copy link
Contributor

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reviewed a small portion of all changes.

storage_options: StorageOptions = ...,
engine_kwargs: dict[str, Any] | None = ...,
) -> None: ...
def __fspath__(self): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is functional: https://docs.python.org/3/library/os.html#os.PathLike.__fspath__

should return a string, according to the implementation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since not documented, the question is do we need it, happy to revert and mark the return type as str, let me know your view

skipna: bool = ...,
): ...
def median(
def __init__(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think __new__ is preferred over __init__. It is easier to understand the return types in __new__ than the typing hint of self in __init__.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

freq: Frequency | None = None,
copy: bool = False,
) -> None: ...
__rmul__ = ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also drop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay will drop, I wanted to keep it concise but happy to do more.


class StringArray(PandasArray):
def __init__(self, values, copy: bool = ...) -> None: ...
def __arrow_array__(self, type=...): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it will revert

def __init__(self, values, copy: bool = ...) -> None: ...
def __arrow_array__(self, type=...): ...
def __setitem__(self, key, value) -> None: ...
def value_counts(self, dropna: bool = True): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not find this one in the base classes, should probably keep it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay will keep and add a test

class PeriodArray(DatetimeLikeArrayMixin, DatelikeOps):
__array_priority__: int = ...
def __init__(self, values, freq=..., dtype=..., copy: bool = ...) -> None: ...
def __init__(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__new__ instead of __init__?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

def __init__(self, values, freq=..., dtype=..., copy: bool = ...) -> None: ...
def __init__(
self,
values: Series[PeriodDtype] | npt.NDArray[np.integer] | PeriodIndex,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
values: Series[PeriodDtype] | npt.NDArray[np.integer] | PeriodIndex,
values: np_ndarray_anyint | PeriodArray | PeriodIndex | Series[Period],

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Ellipsis = "..."

class SparseArray(ExtensionArray, ExtensionOpsMixin):
def __init__(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__new__ instead of __init__?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it makes a difference here since we have only one value.

sparse_index: SparseIndex | None = None,
fill_value: Scalar | None = None,
kind: str = "integer",
dtype: np.dtype | SparseDtype | None = ...,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to distinguish >= 3.11 (np.dtype) and 3.10 (np.dtype[Any])

Comment on lines 41 to 50
@property
def sp_index(self): ...
@property
def sp_values(self): ...
@property
def dtype(self): ...
@property
def fill_value(self): ...
@fill_value.setter
def fill_value(self, value) -> None: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing them might not be a good idea. They seem to be the core use case of SpareArray. We can raise issues in Pandas for the proper documentation.

@overload
def __getitem__(self, item: SequenceIndexer) -> Self: ...
def __iter__(self): ...
def __invert__(self): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in ExtensionArray, keep

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

def __array__(
self, dtype: NpDtype | None = None, copy: bool | None = None
) -> np_1darray: ...
def __arrow_array__(self, type=...): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep

@property
def nbytes(self) -> int: ...
def copy(self): ...
def value_counts(self, dropna: bool = True): ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 27 to 34
if sys.version_info >= (3, 11):
def __init__(
self, values: AnyArrayLike, mask: np_1darray, copy: bool = ...
) -> None: ...
else:
def __init__(
self, values: AnyArrayLike, mask: np.ndarray, copy: bool = ...
) -> None: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self, values: AnyArrayLike, mask: np_ndarray, copy: bool = ... would do in all cases

def month_name(self, locale=...): ...
def day_name(self, locale=...): ...
) -> Self: ...
def to_pydatetime(self) -> npt.NDArray[np.object_]: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe np_1darray_object, also in other cases here

is_year_end = ...
is_leap_year = ...
def to_julian_date(self): ...
def to_julian_date(self) -> npt.NDArray[np.float64]: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe np_1darray_float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants