Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Irv committed Feb 14, 2024
2 parents 98a2731 + 23b35e4 commit 7e5dab8
Show file tree
Hide file tree
Showing 76 changed files with 3,692 additions and 2,038 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ ci:
autofix_prs: false
repos:
- repo: https://github.com/python/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.1
hooks:
- id: ruff
args: [
Expand Down
2 changes: 0 additions & 2 deletions pandas-stubs/_libs/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ from typing import (
)

import numpy as np
from pandas import Interval
from typing_extensions import (
TypeAlias,
TypeGuard,
Expand All @@ -21,7 +20,6 @@ def infer_dtype(value: object, skipna: bool = ...) -> str: ...
def is_iterator(obj: object) -> bool: ...
def is_scalar(val: object) -> bool: ...
def is_list_like(obj: object, allow_sets: bool = ...) -> bool: ...
def is_interval(val: object) -> TypeGuard[Interval]: ...
def is_complex(val: object) -> TypeGuard[complex]: ...
def is_bool(val: object) -> TypeGuard[bool | np.bool_]: ...
def is_integer(val: object) -> TypeGuard[int | np.integer]: ...
Expand Down
5 changes: 4 additions & 1 deletion pandas-stubs/_libs/properties.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ class CachedProperty:
def __get__(self, obj, typ): ...
def __set__(self, obj, value) -> None: ...

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

class AxisProperty:
def __init__(self, axis: int = ..., doc: str = ...) -> None: ...
Expand Down
9 changes: 8 additions & 1 deletion pandas-stubs/_libs/tslibs/nattype.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ from datetime import (
)

import numpy as np
from typing_extensions import TypeAlias
from typing_extensions import (
Self,
TypeAlias,
)

from pandas._libs.tslibs.period import Period
from pandas._typing import TimeUnit

NaT: NaTType
iNaT: int
Expand Down Expand Up @@ -121,3 +125,6 @@ class NaTType:
__le__: _NatComparison
__gt__: _NatComparison
__ge__: _NatComparison
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...
9 changes: 3 additions & 6 deletions pandas-stubs/_libs/tslibs/period.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ class PeriodMixin:
class Period(PeriodMixin):
def __init__(
self,
value: Period
| str
| datetime.datetime
| datetime.date
| Timestamp
| None = ...,
value: (
Period | str | datetime.datetime | datetime.date | Timestamp | None
) = ...,
freq: str | BaseOffset | None = ...,
ordinal: int | None = ...,
year: int | None = ...,
Expand Down
8 changes: 7 additions & 1 deletion pandas-stubs/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ from pandas._libs.tslibs import (
)
from pandas._libs.tslibs.period import Period
from pandas._libs.tslibs.timestamps import Timestamp
from pandas._typing import npt
from pandas._typing import (
TimeUnit,
npt,
)

class Components(NamedTuple):
days: int
Expand Down Expand Up @@ -390,3 +393,6 @@ class Timedelta(timedelta):
@property
def components(self) -> Components: ...
def view(self, dtype: npt.DTypeLike = ...) -> object: ...
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...
4 changes: 4 additions & 0 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ from pandas._libs.tslibs import (
Timedelta,
)
from pandas._typing import (
TimeUnit,
np_ndarray_bool,
npt,
)
Expand Down Expand Up @@ -310,3 +311,6 @@ class Timestamp(datetime):
def days_in_month(self) -> int: ...
@property
def daysinmonth(self) -> int: ...
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...
23 changes: 22 additions & 1 deletion pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ from pandas.core.dtypes.dtypes import (

from pandas.io.formats.format import EngFormatter

# `Incomplete` is equivalent to `Any`. Use it to annotate symbols that you don't
# know the type of yet and that should be changed in the future. Use `Any` only
# where it is the only acceptable type.
Incomplete: TypeAlias = Any

ArrayLike: TypeAlias = ExtensionArray | np.ndarray
AnyArrayLike: TypeAlias = Index | Series | np.ndarray
PythonScalar: TypeAlias = str | bool | complex
Expand Down Expand Up @@ -80,6 +85,10 @@ class FulldatetimeDict(YearMonthDayDict, total=False):
us: DatetimeDictArg
ns: DatetimeDictArg

CorrelationMethod: TypeAlias = (
Literal["pearson", "kendall", "spearman"]
| Callable[[np.ndarray, np.ndarray], float]
)
# dtypes
NpDtype: TypeAlias = str | np.dtype[np.generic] | type[str | complex | bool | object]
Dtype: TypeAlias = ExtensionDtype | NpDtype
Expand Down Expand Up @@ -444,6 +453,7 @@ class SequenceNotStr(Protocol[_T_co]):
IndexLabel: TypeAlias = Hashable | Sequence[Hashable]
Label: TypeAlias = Hashable | None
Level: TypeAlias = Hashable | int
Shape: TypeAlias = tuple[int, ...]
Suffixes: TypeAlias = tuple[str | None, str | None]
Ordered: TypeAlias = bool | None
JSONSerializable: TypeAlias = PythonScalar | list | dict
Expand All @@ -469,8 +479,11 @@ AggFuncTypeSeriesToFrame: TypeAlias = list[AggFuncTypeBase] | AggFuncTypeDictSer
AggFuncTypeFrame: TypeAlias = (
AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDictFrame
)
AggFuncTypeDict: TypeAlias = AggFuncTypeDictSeries | AggFuncTypeDictFrame
AggFuncType: TypeAlias = AggFuncTypeBase | list[AggFuncTypeBase] | AggFuncTypeDict

num: TypeAlias = complex
AxisInt: TypeAlias = int
AxisIndex: TypeAlias = Literal["index", 0]
AxisColumn: TypeAlias = Literal["columns", 1]
Axis: TypeAlias = AxisIndex | AxisColumn
Expand Down Expand Up @@ -563,9 +576,12 @@ IndexT = TypeVar("IndexT", bound=Index)
IntervalT = TypeVar("IntervalT", bound=Interval)
IntervalClosedType: TypeAlias = Literal["left", "right", "both", "neither"]

ScalarIndexer: TypeAlias = int | np.integer
SequenceIndexer: TypeAlias = slice | list[int] | np.ndarray
PositionalIndexer: TypeAlias = ScalarIndexer | SequenceIndexer
TakeIndexer: TypeAlias = Sequence[int] | Sequence[np.integer] | npt.NDArray[np.integer]

IgnoreRaiseCoerce: TypeAlias = Literal["ignore", "raise", "coerce"]
RaiseCoerce: TypeAlias = Literal["raise", "coerce"]

# Shared by functions such as drop and astype
IgnoreRaise: TypeAlias = Literal["ignore", "raise"]
Expand Down Expand Up @@ -758,5 +774,10 @@ RandomState: TypeAlias = (
| np.random.BitGenerator
| np.random.RandomState
)
Frequency: TypeAlias = str | BaseOffset
TimeUnit: TypeAlias = Literal["s", "ms", "us", "ns"]
TimeGrouperOrigin: TypeAlias = (
Timestamp | Literal["epoch", "start", "start_day", "end", "end_day"]
)

__all__ = ["npt", "type_t"]
1 change: 0 additions & 1 deletion pandas-stubs/api/types/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from pandas.core.dtypes.api import (
is_hashable as is_hashable,
is_integer as is_integer,
is_integer_dtype as is_integer_dtype,
is_interval as is_interval,
is_iterator as is_iterator,
is_list_like as is_list_like,
is_named_tuple as is_named_tuple,
Expand Down
5 changes: 5 additions & 0 deletions pandas-stubs/core/arrays/datetimelike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ from pandas.core.arrays.base import (
ExtensionArray,
ExtensionOpsMixin,
)
from typing_extensions import Self

from pandas._libs import (
NaT as NaT,
NaTType as NaTType,
)
from pandas._typing import TimeUnit

class DatelikeOps:
def strftime(self, date_format): ...

class TimelikeOps:
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit) -> Self: ...
def round(self, freq, ambiguous: str = ..., nonexistent: str = ...): ...
def floor(self, freq, ambiguous: str = ..., nonexistent: str = ...): ...
def ceil(self, freq, ambiguous: str = ..., nonexistent: str = ...): ...
Expand Down
15 changes: 13 additions & 2 deletions pandas-stubs/core/base.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from collections.abc import Iterator
from collections.abc import (
Hashable,
Iterator,
)
from typing import (
Any,
Generic,
Literal,
final,
)

import numpy as np
Expand All @@ -19,13 +24,19 @@ from pandas._typing import (
Scalar,
npt,
)
from pandas.util._decorators import cache_readonly

class NoNewAttributesMixin:
def __setattr__(self, key, value) -> None: ...
def __setattr__(self, key: str, value: Any) -> None: ...

class SelectionMixin(Generic[NDFrameT]):
obj: NDFrameT
exclusions: frozenset[Hashable]
@final
@cache_readonly
def ndim(self) -> int: ...
def __getitem__(self, key): ...
def aggregate(self, func, *args, **kwargs): ...

class IndexOpsMixin(OpsMixin, Generic[S1]):
__array_priority__: int = ...
Expand Down
1 change: 0 additions & 1 deletion pandas-stubs/core/dtypes/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ from pandas.core.dtypes.common import (
is_hashable as is_hashable,
is_integer as is_integer,
is_integer_dtype as is_integer_dtype,
is_interval as is_interval,
is_iterator as is_iterator,
is_list_like as is_list_like,
is_named_tuple as is_named_tuple,
Expand Down
1 change: 0 additions & 1 deletion pandas-stubs/core/dtypes/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ from pandas.core.dtypes.inference import (
is_float as is_float,
is_hashable as is_hashable,
is_integer as is_integer,
is_interval as is_interval,
is_iterator as is_iterator,
is_list_like as is_list_like,
is_named_tuple as is_named_tuple,
Expand Down
1 change: 0 additions & 1 deletion pandas-stubs/core/dtypes/inference.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ is_integer = lib.is_integer
is_float = lib.is_float
is_complex = lib.is_complex
is_scalar = lib.is_scalar
is_interval = lib.is_interval
is_list_like = lib.is_list_like
is_iterator = lib.is_iterator

Expand Down
Loading

0 comments on commit 7e5dab8

Please sign in to comment.