8000 TYP: ExtensionArray delete() and searchsorted() by Dr-Irv · Pull Request #41513 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TYP: ExtensionArray delete() and searchsorted() #41513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Sep 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
searchsorted typing updates throughout
  • Loading branch information
Dr-Irv committed May 17, 2021
commit cce79a98c577bf3fc35f5e811ae0a2cd37ccf0bf
28 changes: 14 additions & 14 deletions pandas/core/indexes/extension.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""
Shared methods for Index subclasses backed by ExtensionArray.
"""
from __future__ import annotations

from typing import (
TYPE_CHECKING,
Hashable,
List,
Type,
TypeVar,
Union,
)

import numpy as np

from pandas._typing import (
ArrayLike,
NumpySorter,
Scalar,
)
from pandas.compat.numpy import function as nv
from pandas.errors import AbstractMethodError
Expand Down Expand Up @@ -127,7 +127,7 @@ def method(self, *args, **kwargs):
return method


def inherit_names(names: List[str], delegate, cache: bool = False, wrap: bool = False):
def inherit_names(names: list[str], delegate, cache: bool = False, wrap: bool = False):
"""
Class decorator to pin attributes from an ExtensionArray to a Index subclass.

Expand Down Expand Up @@ -237,20 +237,20 @@ class ExtensionIndex(Index):
# The base class already passes through to _data:
# size, __len__, dtype

_data: Union[IntervalArray, NDArrayBackedExtensionArray]
_data: IntervalArray | NDArrayBackedExtensionArray

_data_cls: Union[
Type[Categorical],
Type[DatetimeArray],
Type[TimedeltaArray],
Type[PeriodArray],
Type[IntervalArray],
]
_data_cls: (
type[Categorical]
| type[DatetimeArray]
| type[TimedeltaArray]
| type[PeriodArray]
| type[IntervalArray]
)

@classmethod
def _simple_new(
cls,
array: Union[IntervalArray, NDArrayBackedExtensionArray],
array: IntervalArray | NDArrayBackedExtensionArray,
name: Hashable = None,
):
"""
Expand Down Expand Up @@ -301,7 +301,7 @@ def __getitem__(self, key):

def searchsorted(
self,
value: ArrayLike | object,
value: Scalar,
side: Literal["left", "right"] = "left",
sorter: NumpySorter = None,
) -> np.ndarray:
Expand Down
0