Skip to content

Commit 7e5dab8

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 98a2731 + 23b35e4 commit 7e5dab8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3692
-2038
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ ci:
33
autofix_prs: false
44
repos:
55
- repo: https://github.com/python/black
6-
rev: 23.12.1
6+
rev: 24.1.1
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
1010
rev: 5.13.2
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.1.9
14+
rev: v0.2.1
1515
hooks:
1616
- id: ruff
1717
args: [

pandas-stubs/_libs/lib.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ from typing import (
55
)
66

77
import numpy as np
8-
from pandas import Interval
98
from typing_extensions import (
109
TypeAlias,
1110
TypeGuard,
@@ -21,7 +20,6 @@ def infer_dtype(value: object, skipna: bool = ...) -> str: ...
2120
def is_iterator(obj: object) -> bool: ...
2221
def is_scalar(val: object) -> bool: ...
2322
def is_list_like(obj: object, allow_sets: bool = ...) -> bool: ...
24-
def is_interval(val: object) -> TypeGuard[Interval]: ...
2523
def is_complex(val: object) -> TypeGuard[complex]: ...
2624
def is_bool(val: object) -> TypeGuard[bool | np.bool_]: ...
2725
def is_integer(val: object) -> TypeGuard[int | np.integer]: ...

pandas-stubs/_libs/properties.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ class CachedProperty:
55
def __get__(self, obj, typ): ...
66
def __set__(self, obj, value) -> None: ...
77

8-
cache_readonly: CachedProperty = ...
8+
# note: this is a lie to make type checkers happy (they special
9+
# case property). cache_readonly uses attribute names similar to
10+
# property (fget) but it does not provide fset and fdel.
11+
cache_readonly = property
912

1013
class AxisProperty:
1114
def __init__(self, axis: int = ..., doc: str = ...) -> None: ...

pandas-stubs/_libs/tslibs/nattype.pyi

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ from datetime import (
55
)
66

77
import numpy as np
8-
from typing_extensions import TypeAlias
8+
from typing_extensions import (
9+
Self,
10+
TypeAlias,
11+
)
912

1013
from pandas._libs.tslibs.period import Period
14+
from pandas._typing import TimeUnit
1115

1216
NaT: NaTType
1317
iNaT: int
@@ -121,3 +125,6 @@ class NaTType:
121125
__le__: _NatComparison
122126
__gt__: _NatComparison
123127
__ge__: _NatComparison
128+
@property
129+
def unit(self) -> TimeUnit: ...
130+
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...

pandas-stubs/_libs/tslibs/period.pyi

+3-6
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@ class PeriodMixin:
6060
class Period(PeriodMixin):
6161
def __init__(
6262
self,
63-
value: Period
64-
| str
65-
| datetime.datetime
66-
| datetime.date
67-
| Timestamp
68-
| None = ...,
63+
value: (
64+
Period | str | datetime.datetime | datetime.date | Timestamp | None
65+
) = ...,
6966
freq: str | BaseOffset | None = ...,
7067
ordinal: int | None = ...,
7168
year: int | None = ...,

pandas-stubs/_libs/tslibs/timedeltas.pyi

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ from pandas._libs.tslibs import (
3131
)
3232
from pandas._libs.tslibs.period import Period
3333
from pandas._libs.tslibs.timestamps import Timestamp
34-
from pandas._typing import npt
34+
from pandas._typing import (
35+
TimeUnit,
36+
npt,
37+
)
3538

3639
class Components(NamedTuple):
3740
days: int
@@ -390,3 +393,6 @@ class Timedelta(timedelta):
390393
@property
391394
def components(self) -> Components: ...
392395
def view(self, dtype: npt.DTypeLike = ...) -> object: ...
396+
@property
397+
def unit(self) -> TimeUnit: ...
398+
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...

pandas-stubs/_libs/tslibs/timestamps.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from pandas._libs.tslibs import (
3838
Timedelta,
3939
)
4040
from pandas._typing import (
41+
TimeUnit,
4142
np_ndarray_bool,
4243
npt,
4344
)
@@ -310,3 +311,6 @@ class Timestamp(datetime):
310311
def days_in_month(self) -> int: ...
311312
@property
312313
def daysinmonth(self) -> int: ...
314+
@property
315+
def unit(self) -> TimeUnit: ...
316+
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...

pandas-stubs/_typing.pyi

+22-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ from pandas.core.dtypes.dtypes import (
4848

4949
from pandas.io.formats.format import EngFormatter
5050

51+
# `Incomplete` is equivalent to `Any`. Use it to annotate symbols that you don't
52+
# know the type of yet and that should be changed in the future. Use `Any` only
53+
# where it is the only acceptable type.
54+
Incomplete: TypeAlias = Any
55+
5156
ArrayLike: TypeAlias = ExtensionArray | np.ndarray
5257
AnyArrayLike: TypeAlias = Index | Series | np.ndarray
5358
PythonScalar: TypeAlias = str | bool | complex
@@ -80,6 +85,10 @@ class FulldatetimeDict(YearMonthDayDict, total=False):
8085
us: DatetimeDictArg
8186
ns: DatetimeDictArg
8287

88+
CorrelationMethod: TypeAlias = (
89+
Literal["pearson", "kendall", "spearman"]
90+
| Callable[[np.ndarray, np.ndarray], float]
91+
)
8392
# dtypes
8493
NpDtype: TypeAlias = str | np.dtype[np.generic] | type[str | complex | bool | object]
8594
Dtype: TypeAlias = ExtensionDtype | NpDtype
@@ -444,6 +453,7 @@ class SequenceNotStr(Protocol[_T_co]):
444453
IndexLabel: TypeAlias = Hashable | Sequence[Hashable]
445454
Label: TypeAlias = Hashable | None
446455
Level: TypeAlias = Hashable | int
456+
Shape: TypeAlias = tuple[int, ...]
447457
Suffixes: TypeAlias = tuple[str | None, str | None]
448458
Ordered: TypeAlias = bool | None
449459
JSONSerializable: TypeAlias = PythonScalar | list | dict
@@ -469,8 +479,11 @@ AggFuncTypeSeriesToFrame: TypeAlias = list[AggFuncTypeBase] | AggFuncTypeDictSer
469479
AggFuncTypeFrame: TypeAlias = (
470480
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDictFrame
471481
)
482+
AggFuncTypeDict: TypeAlias = AggFuncTypeDictSeries | AggFuncTypeDictFrame
483+
AggFuncType: TypeAlias = AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict
472484

473485
num: TypeAlias = complex
486+
AxisInt: TypeAlias = int
474487
AxisIndex: TypeAlias = Literal["index", 0]
475488
AxisColumn: TypeAlias = Literal["columns", 1]
476489
Axis: TypeAlias = AxisIndex | AxisColumn
@@ -563,9 +576,12 @@ IndexT = TypeVar("IndexT", bound=Index)
563576
IntervalT = TypeVar("IntervalT", bound=Interval)
564577
IntervalClosedType: TypeAlias = Literal["left", "right", "both", "neither"]
565578

579+
ScalarIndexer: TypeAlias = int | np.integer
580+
SequenceIndexer: TypeAlias = slice | list[int] | np.ndarray
581+
PositionalIndexer: TypeAlias = ScalarIndexer | SequenceIndexer
566582
TakeIndexer: TypeAlias = Sequence[int] | Sequence[np.integer] | npt.NDArray[np.integer]
567583

568-
IgnoreRaiseCoerce: TypeAlias = Literal["ignore", "raise", "coerce"]
584+
RaiseCoerce: TypeAlias = Literal["raise", "coerce"]
569585

570586
# Shared by functions such as drop and astype
571587
IgnoreRaise: TypeAlias = Literal["ignore", "raise"]
@@ -758,5 +774,10 @@ RandomState: TypeAlias = (
758774
| np.random.BitGenerator
759775
| np.random.RandomState
760776
)
777+
Frequency: TypeAlias = str | BaseOffset
778+
TimeUnit: TypeAlias = Literal["s", "ms", "us", "ns"]
779+
TimeGrouperOrigin: TypeAlias = (
780+
Timestamp | Literal["epoch", "start", "start_day", "end", "end_day"]
781+
)
761782

762783
__all__ = ["npt", "type_t"]

pandas-stubs/api/types/__init__.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ from pandas.core.dtypes.api import (
1919
is_hashable as is_hashable,
2020
is_integer as is_integer,
2121
is_integer_dtype as is_integer_dtype,
22-
is_interval as is_interval,
2322
is_iterator as is_iterator,
2423
is_list_like as is_list_like,
2524
is_named_tuple as is_named_tuple,

pandas-stubs/core/arrays/datetimelike.pyi

+5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ from pandas.core.arrays.base import (
55
ExtensionArray,
66
ExtensionOpsMixin,
77
)
8+
from typing_extensions import Self
89

910
from pandas._libs import (
1011
NaT as NaT,
1112
NaTType as NaTType,
1213
)
14+
from pandas._typing import TimeUnit
1315

1416
class DatelikeOps:
1517
def strftime(self, date_format): ...
1618

1719
class TimelikeOps:
20+
@property
21+
def unit(self) -> TimeUnit: ...
22+
def as_unit(self, unit: TimeUnit) -> Self: ...
1823
def round(self, freq, ambiguous: str = ..., nonexistent: str = ...): ...
1924
def floor(self, freq, ambiguous: str = ..., nonexistent: str = ...): ...
2025
def ceil(self, freq, ambiguous: str = ..., nonexistent: str = ...): ...

pandas-stubs/core/base.pyi

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
from collections.abc import Iterator
1+
from collections.abc import (
2+
Hashable,
3+
Iterator,
4+
)
25
from typing import (
6+
Any,
37
Generic,
48
Literal,
9+
final,
510
)
611

712
import numpy as np
@@ -19,13 +24,19 @@ from pandas._typing import (
1924
Scalar,
2025
npt,
2126
)
27+
from pandas.util._decorators import cache_readonly
2228

2329
class NoNewAttributesMixin:
24-
def __setattr__(self, key, value) -> None: ...
30+
def __setattr__(self, key: str, value: Any) -> None: ...
2531

2632
class SelectionMixin(Generic[NDFrameT]):
33+
obj: NDFrameT
34+
exclusions: frozenset[Hashable]
35+
@final
36+
@cache_readonly
2737
def ndim(self) -> int: ...
2838
def __getitem__(self, key): ...
39+
def aggregate(self, func, *args, **kwargs): ...
2940

3041
class IndexOpsMixin(OpsMixin, Generic[S1]):
3142
__array_priority__: int = ...

pandas-stubs/core/dtypes/api.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ from pandas.core.dtypes.common import (
1717
is_hashable as is_hashable,
1818
is_integer as is_integer,
1919
is_integer_dtype as is_integer_dtype,
20-
is_interval as is_interval,
2120
is_iterator as is_iterator,
2221
is_list_like as is_list_like,
2322
is_named_tuple as is_named_tuple,

pandas-stubs/core/dtypes/common.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ from pandas.core.dtypes.inference import (
1717
is_float as is_float,
1818
is_hashable as is_hashable,
1919
is_integer as is_integer,
20-
is_interval as is_interval,
2120
is_iterator as is_iterator,
2221
is_list_like as is_list_like,
2322
is_named_tuple as is_named_tuple,

pandas-stubs/core/dtypes/inference.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ is_integer = lib.is_integer
55
is_float = lib.is_float
66
is_complex = lib.is_complex
77
is_scalar = lib.is_scalar
8-
is_interval = lib.is_interval
98
is_list_like = lib.is_list_like
109
is_iterator = lib.is_iterator
1110

0 commit comments

Comments
 (0)