Skip to content

Commit 4b8183d

Browse files
committed
use class, use pyright: strict
1 parent ca10bf2 commit 4b8183d

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

pandas-stubs/_typing.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ S2 = TypeVar(
576576
| list[str],
577577
)
578578

579-
UnknownSeries: TypeAlias = Series[Any]
580-
UnknownIndex: TypeAlias = Index[Any]
579+
class UnknownSeries(Series[Any]): ...
580+
class UnknownIndex(Index[Any]): ...
581581

582582
IndexingInt: TypeAlias = (
583583
int | np.int_ | np.integer | np.unsignedinteger | np.signedinteger | np.int8

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Index(IndexOpsMixin[S1]):
6767
__hash__: ClassVar[None] # type: ignore[assignment]
6868
# overloads with additional dtypes
6969
@overload
70-
def __new__( # pyright: ignore[reportOverlappingOverload]
70+
def __new__(
7171
cls,
7272
data: Sequence[int | np.integer] | IndexOpsMixin[int] | np_ndarray_anyint,
7373
*,

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
249249
copy: bool = ...,
250250
) -> Series[float]: ...
251251
@overload
252-
def __new__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
252+
def __new__( # type: ignore[overload-overlap]
253253
cls,
254254
data: Sequence[Never],
255255
index: Axes | None = ...,

pandas-stubs/core/strings.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: strict
12
from collections.abc import (
23
Callable,
34
Sequence,
@@ -110,7 +111,7 @@ class StringMethods(NoNewAttributesMixin, Generic[T, _TS, _TM, _TS2]):
110111
def join(self, sep: str) -> T: ...
111112
def contains(
112113
self,
113-
pat: str | re.Pattern,
114+
pat: str | re.Pattern[str],
114115
case: bool = ...,
115116
flags: int = ...,
116117
na: Scalar | NaTType | None = ...,

tests/test_series.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from pandas._typing import (
5050
DtypeObj,
5151
Scalar,
52+
UnknownSeries,
5253
)
5354

5455
from tests import (
@@ -1594,7 +1595,7 @@ def test_string_accessors():
15941595
check(assert_type(s3.str.extract(r"([ab])?(\d)"), pd.DataFrame), pd.DataFrame)
15951596
check(assert_type(s3.str.extractall(r"([ab])?(\d)"), pd.DataFrame), pd.DataFrame)
15961597
check(assert_type(s.str.find("p"), pd.Series), pd.Series)
1597-
check(assert_type(s.str.findall("pp"), pd.Series), pd.Series)
1598+
check(assert_type(s.str.findall("pp"), UnknownSeries), pd.Series)
15981599
check(assert_type(s.str.fullmatch("apple"), "pd.Series[bool]"), pd.Series, np.bool_)
15991600
check(assert_type(s.str.get(2), pd.Series), pd.Series)
16001601
check(assert_type(s.str.get_dummies(), pd.DataFrame), pd.DataFrame)

0 commit comments

Comments
 (0)