-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Improved the type stubs in the _libs directory to help with type checking #43744
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from typing import FrozenSet, Tuple | ||
|
||
import numpy as np | ||
|
||
class IntervalMixin: | ||
@property | ||
def _left(self) -> object: ... | ||
@property | ||
def _right(self) -> object: ... | ||
@property | ||
def closed_left(self) -> bool: ... | ||
@property | ||
def closed_right(self) -> bool: ... | ||
@property | ||
def open_left(self) -> bool: ... | ||
@property | ||
def open_right(self) -> bool: ... | ||
@property | ||
def mid(self) -> float: ... | ||
@property | ||
def length(self) -> float: ... | ||
@property | ||
def is_empty(self) -> bool: ... | ||
def _check_closed_matches(self, other: IntervalMixin, name: str = ...) -> None: ... | ||
|
||
class Interval(IntervalMixin): | ||
def __init__(self, left: object, right: object, closed: str = ...) -> None: ... | ||
@property | ||
def closed(self) -> str: ... | ||
@property | ||
def left(self) -> object: ... | ||
@property | ||
def right(self) -> object: ... | ||
def __str__(self) -> str: ... | ||
def __add__(self, y: Interval) -> Interval: ... | ||
def __sub__(self, y: Interval) -> Interval: ... | ||
def __mul__(self, y: Interval) -> Interval: ... | ||
def __trudeiv__(self, y: Interval) -> Interval: ... | ||
def __floordiv__(self, y: Interval) -> Interval: ... | ||
def __overlaps__(self, other: Interval) -> bool: ... | ||
|
||
VALID_CLOSED: FrozenSet[str] | ||
|
||
def intervals_to_interval_bounds( | ||
intervals: np.ndarray, valdiate_closed: bool = ... | ||
) -> Tuple[object, object, str]: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class C_NAType: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any benefit/reason to include the C class. |
||
class NAType(C_NAType): ... | ||
|
||
NA: NAType | ||
|
||
def is_matching_na( | ||
left: object, right: object, nan_matches_none: bool = ... | ||
) -> bool: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cache_readonly = property | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will need many ignore statements, since there are quite a few places where a typed I think you will also need to add annotations for |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ iNaT: int | |
nat_strings: set[str] | ||
|
||
def is_null_datetimelike(val: object, inat_is_null: bool = ...) -> bool: ... | ||
def checknull_with_nat(val: object) -> bool: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to expose this to python code. |
||
|
||
class NaTType(datetime): | ||
value: np.int64 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class OutOfBoundsDatetime(ValueError): ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
from __future__ import annotations | ||
from datetime import datetime | ||
from typing import Any, Tuple, Union | ||
from datetime import timedelta | ||
|
||
class BaseOffset: | ||
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ... | ||
def __eq__(self, other) -> bool: ... | ||
def __ne__(self, other) -> bool: ... | ||
def __hash__(self) -> int: ... | ||
@property | ||
def kwds(self) -> dict: ... | ||
@property | ||
def base(self) -> BaseOffset: ... | ||
def __add__(self, other) -> BaseOffset: ... | ||
def __sub__(self, other) -> BaseOffset: ... | ||
def __call__(self, other): ... | ||
def __mul__(self, other): ... | ||
def __neg__(self) -> BaseOffset: ... | ||
def copy(self) -> BaseOffset: ... | ||
def __repr__(self) -> str: ... | ||
@property | ||
def name(self) -> str: ... | ||
@property | ||
def rule_code(self) -> str: ... | ||
def freqstr(self) -> str: ... | ||
# Next one is problematic due to circular imports | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do it inside a |
||
# def apply_index(self, dtindex: DatetimeIndex) -> DatetimeIndex: ... | ||
def apply_index(self, dtindex): ... | ||
def _apply_array(self, dtarr) -> None: ... | ||
def rollback(self, dt: datetime) -> datetime: ... | ||
def rollforward(self, dt: datetime) -> datetime: ... | ||
def is_on_offset(self, dt: datetime) -> bool: ... | ||
def __setstate__(self, state) -> None: ... | ||
def __getstate__(self): ... | ||
@property | ||
def nanos(self) -> int: ... | ||
def onOffset(self, dt: datetime) -> bool: ... | ||
def isAnchored(self) -> bool: ... | ||
def is_anchored(self) -> bool: ... | ||
|
||
class SingleConstructorOffset(BaseOffset): | ||
@classmethod | ||
def _from_name(cls, suffix=None): ... | ||
def __reduce__(self): ... | ||
|
||
def to_offset( | ||
freq: Union[str, Tuple, timedelta, BaseOffset, None] | ||
) -> Union[BaseOffset, None]: ... | ||
|
||
class Tick(SingleConstructorOffset): | ||
def __init__(self, n: int = ..., normalize: bool = ...) -> None: ... | ||
|
||
class Day(Tick): ... | ||
class Hour(Tick): ... | ||
class Minute(Tick): ... | ||
class Second(Tick): ... | ||
class Milli(Tick): ... | ||
class Micro(Tick): ... | ||
class Nano(Tick): ... | ||
|
||
class RelativeDeltaOffset(BaseOffset): | ||
def __init__(self, n: int = ..., normalize: bool = ..., **kwds: Any) -> None: ... | ||
|
||
class BusinessMixin(SingleConstructorOffset): ... | ||
class BusinessDay(BusinessMixin): ... | ||
class BusinessHour(BusinessMixin): ... | ||
class WeekOfMonthMixin(SingleConstructorOffset): ... | ||
class YearOffset(SingleConstructorOffset): ... | ||
class BYearEnd(YearOffset): ... | ||
class BYearBegin(YearOffset): ... | ||
class YearEnd(YearOffset): ... | ||
class YearBegin(YearOffset): ... | ||
class QuarterOffset(SingleConstructorOffset): ... | ||
class BQuarterEnd(QuarterOffset): ... | ||
class BQuarterBegin(QuarterOffset): ... | ||
class QuarterEnd(QuarterOffset): ... | ||
class QuarterBegin(QuarterOffset): ... | ||
class MonthOffset(SingleConstructorOffset): ... | ||
class MonthEnd(MonthOffset): ... | ||
class MonthBegin(MonthOffset): ... | ||
class BusinessMonthEnd(MonthOffset): ... | ||
class BusinessMonthBegin(MonthOffset): ... | ||
class SemiMonthOffset(SingleConstructorOffset): ... | ||
class SemiMonthEnd(SemiMonthOffset): ... | ||
class SemiMonthBegin(SemiMonthOffset): ... | ||
class Week(SingleConstructorOffset): ... | ||
class WeekOfMonth(WeekOfMonthMixin): ... | ||
class LastWeekOfMonth(WeekOfMonthMixin): ... | ||
class FY5253Mixin(SingleConstructorOffset): ... | ||
class FY5253(FY5253Mixin): ... | ||
class FY5253Quarter(FY5253Mixin): ... | ||
class Easter(SingleConstructorOffset): ... | ||
class _CustomBusinessMonth(BusinessMixin): ... | ||
class CustomBusinessDay(BusinessDay): ... | ||
class CustomBusinessHour(BusinessHour): ... | ||
class CustomBusinessMonthEnd(_CustomBusinessMonth): ... | ||
class CustomBusinessMonthBegin(_CustomBusinessMonth): ... | ||
class DateOffset(RelativeDeltaOffset): ... | ||
|
||
BDay = BusinessDay | ||
BMonthEnd = BusinessMonthEnd | ||
BMonthBegin = BusinessMonthBegin | ||
CBMonthEnd = CustomBusinessMonthEnd | ||
CBMonthBegin = CustomBusinessMonthBegin | ||
CDay = CustomBusinessDay |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ import numpy as np | |
|
||
from pandas._libs.tslibs import ( | ||
BaseOffset, | ||
NaT, | ||
NaTType, | ||
Period, | ||
Timedelta, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valdiate_closed -> validate_closed