Skip to content
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

TYP: a few mismatches found by stubtest #47764

Merged
merged 4 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/algos.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def groupsort_indexer(
np.ndarray, # ndarray[int64_t, ndim=1]
]: ...
def kth_smallest(
a: np.ndarray, # numeric[:]
arr: np.ndarray, # numeric[:]
k: int,
) -> Any: ... # numeric

Expand Down
16 changes: 13 additions & 3 deletions pandas/_libs/groupby.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,28 @@ def group_last(
values: np.ndarray, # ndarray[rank_t, ndim=2]
labels: np.ndarray, # const int64_t[:]
mask: npt.NDArray[np.bool_] | None,
result_mask: npt.NDArray[np.bool_] | None,
result_mask: npt.NDArray[np.bool_] | None = ...,
min_count: int = ..., # Py_ssize_t
is_datetimelike: bool = ...,
) -> None: ...
def group_nth(
out: np.ndarray, # rank_t[:, ::1]
counts: np.ndarray, # int64_t[::1]
values: np.ndarray, # ndarray[rank_t, ndim=2]
labels: np.ndarray, # const int64_t[:]
mask: npt.NDArray[np.bool_] | None,
result_mask: npt.NDArray[np.bool_] | None,
result_mask: npt.NDArray[np.bool_] | None = ...,
min_count: int = ..., # int64_t
rank: int = ..., # int64_t
is_datetimelike: bool = ...,
) -> None: ...
def group_rank(
out: np.ndarray, # float64_t[:, ::1]
values: np.ndarray, # ndarray[rank_t, ndim=2]
labels: np.ndarray, # const int64_t[:]
ngroups: int,
is_datetimelike: bool,
ties_method: Literal["aveage", "min", "max", "first", "dense"] = ...,
ties_method: Literal["average", "min", "max", "first", "dense"] = ...,
ascending: bool = ...,
pct: bool = ...,
na_option: Literal["keep", "top", "bottom"] = ...,
Expand All @@ -136,6 +138,7 @@ def group_max(
values: np.ndarray, # ndarray[groupby_t, ndim=2]
labels: np.ndarray, # const int64_t[:]
min_count: int = ...,
is_datetimelike: bool = ...,
mask: np.ndarray | None = ...,
result_mask: np.ndarray | None = ...,
) -> None: ...
Expand All @@ -145,6 +148,7 @@ def group_min(
values: np.ndarray, # ndarray[groupby_t, ndim=2]
labels: np.ndarray, # const int64_t[:]
min_count: int = ...,
is_datetimelike: bool = ...,
mask: np.ndarray | None = ...,
result_mask: np.ndarray | None = ...,
) -> None: ...
Expand All @@ -154,11 +158,17 @@ def group_cummin(
labels: np.ndarray, # const int64_t[:]
ngroups: int,
is_datetimelike: bool,
mask: np.ndarray | None = ...,
result_mask: np.ndarray | None = ...,
skipna: bool = ...,
) -> None: ...
def group_cummax(
out: np.ndarray, # groupby_t[:, ::1]
values: np.ndarray, # ndarray[groupby_t, ndim=2]
labels: np.ndarray, # const int64_t[:]
ngroups: int,
is_datetimelike: bool,
mask: np.ndarray | None = ...,
result_mask: np.ndarray | None = ...,
skipna: bool = ...,
) -> None: ...
2 changes: 1 addition & 1 deletion pandas/_libs/internals.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def update_blklocs_and_blknos(
loc: int,
nblocks: int,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...

@final
class BlockPlacement:
def __init__(self, val: int | slice | np.ndarray): ...
@property
Expand Down
21 changes: 3 additions & 18 deletions pandas/_libs/join.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def asof_join_backward_on_X_by_Y(
right_by_values: np.ndarray, # by_t[:]
allow_exact_matches: bool = ...,
tolerance: np.number | int | float | None = ...,
use_hashtable: bool = ...,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
def asof_join_forward_on_X_by_Y(
left_values: np.ndarray, # asof_t[:]
Expand All @@ -64,6 +65,7 @@ def asof_join_forward_on_X_by_Y(
right_by_values: np.ndarray, # by_t[:]
allow_exact_matches: bool = ...,
tolerance: np.number | int | float | None = ...,
use_hashtable: bool = ...,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
def asof_join_nearest_on_X_by_Y(
left_values: np.ndarray, # asof_t[:]
Expand All @@ -72,22 +74,5 @@ def asof_join_nearest_on_X_by_Y(
right_by_values: np.ndarray, # by_t[:]
allow_exact_matches: bool = ...,
tolerance: np.number | int | float | None = ...,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
def asof_join_backward(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
allow_exact_matches: bool = ...,
tolerance: np.number | int | float | None = ...,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
def asof_join_forward(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
allow_exact_matches: bool = ...,
tolerance: np.number | int | float | None = ...,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
def asof_join_nearest(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
allow_exact_matches: bool = ...,
tolerance: np.number | int | float | None = ...,
use_hashtable: bool = ...,
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]: ...
3 changes: 2 additions & 1 deletion pandas/_libs/missing.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import numpy as np
from numpy import typing as npt

class NAType: ...
class NAType:
def __new__(cls, *args, **kwargs): ...

NA: NAType

Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/parsers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class TextReader:
skip_blank_lines: bool = ...,
encoding_errors: bytes | str = ...,
): ...
def set_error_bad_lines(self, status: int) -> None: ...
def set_noconvert(self, i: int) -> None: ...
def remove_noconvert(self, i: int) -> None: ...
def close(self) -> None: ...
Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/ccalendar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ def get_firstbday(year: int, month: int) -> int: ...
def get_lastbday(year: int, month: int) -> int: ...
def get_day_of_year(year: int, month: int, day: int) -> int: ...
def get_iso_calendar(year: int, month: int, day: int) -> tuple[int, int, int]: ...
def is_leapyear(year: int) -> bool: ...
def get_week_of_year(year: int, month: int, day: int) -> int: ...
def get_days_in_month(year: int, month: int) -> int: ...
def dayofweek(y: int, m: int, d: int) -> int: ...
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/dtypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class PeriodDtypeBase:

# actually __cinit__
def __new__(cls, code: int): ...
@property
def _freq_group_code(self) -> int: ...
@property
def _resolution_obj(self) -> Resolution: ...
def _get_to_timestamp_base(self) -> int: ...
@property
def _freqstr(self) -> str: ...

class FreqGroup(Enum):
Expand Down
3 changes: 1 addition & 2 deletions pandas/_libs/tslibs/nattype.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ NaT: NaTType
iNaT: int
nat_strings: set[str]

def is_null_datetimelike(val: object, inat_is_null: bool = ...) -> bool: ...

_NaTComparisonTypes = datetime | timedelta | Period | np.datetime64 | np.timedelta64

class _NatComparison:
def __call__(self, other: _NaTComparisonTypes) -> bool: ...

class NaTType:
value: np.int64
@property
def asm8(self) -> np.datetime64: ...
def to_datetime64(self) -> np.datetime64: ...
def to_numpy(
Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/tslibs/offsets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class BaseOffset:
def name(self) -> str: ...
@property
def rule_code(self) -> str: ...
@property
def freqstr(self) -> str: ...
def apply_index(self, dtindex: DatetimeIndex) -> DatetimeIndex: ...
def _apply_array(self, dtarr) -> None: ...
Expand Down
5 changes: 0 additions & 5 deletions pandas/_libs/tslibs/timezones.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ from typing import Callable

import numpy as np

from pandas._typing import npt

# imported from dateutil.tz
dateutil_gettz: Callable[[str], tzinfo]

Expand All @@ -17,9 +15,6 @@ def infer_tzinfo(
start: datetime | None,
end: datetime | None,
) -> tzinfo | None: ...
def get_dst_info(
tz: tzinfo,
) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.int64], str]: ...
def maybe_get_tz(tz: str | int | np.int64 | tzinfo | None) -> tzinfo | None: ...
def get_timezone(tz: tzinfo) -> tzinfo | str: ...
def is_utc(tz: tzinfo | None) -> bool: ...