Skip to content

Add defaults for parameters #1293

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas-stubs/_libs/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class _NoDefault(Enum):
no_default: Final = _NoDefault.no_default
_NoDefaultDoNotUse: TypeAlias = Literal[_NoDefault.no_default] # noqa: PYI047

def infer_dtype(value: object, skipna: bool = ...) -> str: ...
def infer_dtype(value: object, skipna: bool = True) -> 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_list_like(obj: object, allow_sets: bool = True) -> bool: ...
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
22 changes: 11 additions & 11 deletions pandas-stubs/_libs/tslibs/nattype.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,34 @@ class NaTType:
def weekday(self) -> float: ...
def isoweekday(self) -> float: ...
def total_seconds(self) -> float: ...
def today(self, tz: _tzinfo | str | None = ...) -> NaTType: ...
def now(self, tz: _tzinfo | str | None = ...) -> NaTType: ...
def today(self, tz: _tzinfo | str | None = None) -> NaTType: ...
def now(self, tz: _tzinfo | str | None = None) -> NaTType: ...
def to_pydatetime(self) -> NaTType: ...
def date(self) -> NaTType: ...
def round(
self,
freq: Frequency,
ambiguous: bool | Literal["raise"] | NaTType = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: bool | Literal["raise"] | NaTType = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> NaTType: ...
def floor(
self,
freq: Frequency,
ambiguous: bool | Literal["raise"] | NaTType = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: bool | Literal["raise"] | NaTType = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> NaTType: ...
def ceil(
self,
freq: Frequency,
ambiguous: bool | Literal["raise"] | NaTType = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: bool | Literal["raise"] | NaTType = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> NaTType: ...
def tz_convert(self) -> NaTType: ...
def tz_localize(
self,
tz: _tzinfo | str | None,
ambiguous: bool | Literal["raise"] | NaTType = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: bool | Literal["raise"] | NaTType = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> NaTType: ...
def replace(
self,
Expand Down Expand Up @@ -154,4 +154,4 @@ class NaTType:
__ge__: _NatComparison
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = True) -> Self: ...
4 changes: 2 additions & 2 deletions pandas-stubs/_libs/tslibs/period.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ class Period(PeriodMixin):
def day_of_year(self) -> int: ...
@property
def day_of_week(self) -> int: ...
def asfreq(self, freq: str | BaseOffset, how: _PeriodFreqHow = ...) -> Period: ...
def asfreq(self, freq: str | BaseOffset, how: _PeriodFreqHow = "end") -> Period: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether this matters. Code has default of how as "E", but docs say "end"

I'm fine with leaving it as you have it, but open to which way to go.

@classmethod
def now(cls, freq: str | BaseOffset = ...) -> Period: ...
def strftime(self, fmt: str) -> str: ...
def to_timestamp(
self,
freq: str | BaseOffset | None = ...,
how: _PeriodToTimestampHow = ...,
how: _PeriodToTimestampHow = "S",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue as in asfreq(). docs say "S", but code says "start"

I'm fine with leaving it as you have it, but open to which way to go.

) -> Timestamp: ...
2 changes: 1 addition & 1 deletion pandas-stubs/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,4 @@ class Timedelta(timedelta):
def view(self, dtype: npt.DTypeLike = ...) -> object: ...
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = True) -> Self: ...
28 changes: 14 additions & 14 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ class Timestamp(datetime, SupportsIndex):
@classmethod
def utcfromtimestamp(cls, ts: float) -> Self: ...
@classmethod
def today(cls, tz: _tzinfo | str | None = ...) -> Self: ...
def today(cls, tz: _tzinfo | str | None = None) -> Self: ...
@classmethod
def fromordinal(
cls,
ordinal: int,
tz: _tzinfo | str | None = ...,
) -> Self: ...
@classmethod
def now(cls, tz: _tzinfo | str | None = ...) -> Self: ...
def now(cls, tz: _tzinfo | str | None = None) -> Self: ...
@classmethod
def utcnow(cls) -> Self: ...
# error: Signature of "combine" incompatible with supertype "datetime"
Expand Down Expand Up @@ -157,7 +157,7 @@ class Timestamp(datetime, SupportsIndex):
) -> Timestamp: ...
def astimezone(self, tz: _tzinfo | None = ...) -> Self: ...
def ctime(self) -> str: ...
def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
def isoformat(self, sep: str = "T", timespec: str = "auto") -> str: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def isoformat(self, sep: str = "T", timespec: str = "auto") -> str: ...
def isoformat(self, sep: str = "T", timespec: Literal[‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘microseconds’, ‘nanoseconds’]= "auto") -> str: ...

@classmethod
def strptime(cls, date_string: Never, format: Never) -> Never: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def utcoffset(self) -> timedelta | None: ...
Expand Down Expand Up @@ -276,31 +276,31 @@ class Timestamp(datetime, SupportsIndex):
def tz_localize(
self,
tz: TimeZones,
ambiguous: _Ambiguous = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: _Ambiguous = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> Self: ...
def normalize(self) -> Self: ...
# TODO: round/floor/ceil could return NaT?
def round(
self,
freq: str,
ambiguous: _Ambiguous = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: _Ambiguous = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> Self: ...
def floor(
self,
freq: str,
ambiguous: _Ambiguous = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: _Ambiguous = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> Self: ...
def ceil(
self,
freq: str,
ambiguous: _Ambiguous = ...,
nonexistent: TimestampNonexistent = ...,
ambiguous: _Ambiguous = "raise",
nonexistent: TimestampNonexistent = "raise",
) -> Self: ...
def day_name(self, locale: str | None = ...) -> str: ...
def month_name(self, locale: str | None = ...) -> str: ...
def day_name(self, locale: str | None = None) -> str: ...
def month_name(self, locale: str | None = None) -> str: ...
@property
def day_of_week(self) -> int: ...
@property
Expand All @@ -322,6 +322,6 @@ class Timestamp(datetime, SupportsIndex):
def daysinmonth(self) -> int: ...
@property
def unit(self) -> TimeUnit: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = ...) -> Self: ...
def as_unit(self, unit: TimeUnit, round_ok: bool = True) -> Self: ...
# To support slicing
def __index__(self) -> int: ...
106 changes: 53 additions & 53 deletions pandas-stubs/_testing/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ from pandas._typing import (
def assert_almost_equal(
left: T,
right: T,
check_dtype: bool | Literal["equiv"] = ...,
rtol: float = ...,
atol: float = ...,
check_dtype: bool | Literal["equiv"] = "equiv",
rtol: float = 1e-5,
atol: float = 1e-8,
**kwargs,
) -> None: ...
def assert_dict_equal(left: dict, right: dict, compare_keys: bool = ...) -> None: ...
def assert_dict_equal(left: dict, right: dict, compare_keys: bool = True) -> None: ...
def assert_index_equal(
left: Index,
right: Index,
exact: bool | Literal["equiv"] = ...,
check_names: bool = ...,
check_exact: bool = ...,
check_categorical: bool = ...,
check_order: bool = ...,
rtol: float = ...,
atol: float = ...,
obj: str = ...,
exact: bool | Literal["equiv"] = "equiv",
check_names: bool = True,
check_exact: bool = True,
check_categorical: bool = True,
check_order: bool = True,
rtol: float = 1e-5,
atol: float = 1e-8,
obj: str = "Index",
) -> None: ...
def assert_class_equal(
left: T, right: T, exact: bool | Literal["equiv"] = ..., obj: str = ...
left: T, right: T, exact: bool | Literal["equiv"] = True, obj: str = "Input"
) -> None: ...
def assert_attr_equal(
attr: str, left: object, right: object, obj: str = ...
attr: str, left: object, right: object, obj: str = "Attributes"
) -> None: ...
def assert_is_valid_plot_return_object(
objs: Series | np.ndarray | Artist | tuple | dict,
Expand All @@ -67,44 +67,44 @@ def assert_is_sorted(seq: AnyArrayLike) -> None: ...
def assert_categorical_equal(
left: Categorical,
right: Categorical,
check_dtype: bool = ...,
check_category_order: bool = ...,
obj: str = ...,
check_dtype: bool = True,
check_category_order: bool = True,
obj: str = "Categorical",
) -> None: ...
def assert_interval_array_equal(
left: IntervalArray,
right: IntervalArray,
exact: bool | Literal["equiv"] = ...,
obj: str = ...,
exact: bool | Literal["equiv"] = "equiv",
obj: str = "IntervalArray",
) -> None: ...
def assert_period_array_equal(
left: PeriodArray, right: PeriodArray, obj: str = ...
left: PeriodArray, right: PeriodArray, obj: str = "PeriodArray"
) -> None: ...
def assert_datetime_array_equal(
left: DatetimeArray, right: DatetimeArray, check_freq: bool = ...
left: DatetimeArray, right: DatetimeArray, check_freq: bool = True
) -> None: ...
def assert_timedelta_array_equal(
left: TimedeltaArray, right: TimedeltaArray, check_freq: bool = ...
left: TimedeltaArray, right: TimedeltaArray, check_freq: bool = True
) -> None: ...
def assert_numpy_array_equal(
left,
right,
strict_nan: bool = ...,
check_dtype: bool | Literal["equiv"] = ...,
err_msg: str | None = ...,
check_same: Literal["copy", "same"] | None = ...,
obj: str = ...,
index_values: Index | np.ndarray | None = ...,
strict_nan: bool = False,
check_dtype: bool | Literal["equiv"] = True,
err_msg: str | None = None,
check_same: Literal["copy", "same"] | None = None,
obj: str = "numpy array",
index_values: Index | np.ndarray | None = None,
) -> None: ...
def assert_extension_array_equal(
left: ExtensionArray,
right: ExtensionArray,
check_dtype: bool | Literal["equiv"] = ...,
index_values: Index | np.ndarray | None = ...,
check_exact: bool = ...,
rtol: float = ...,
atol: float = ...,
obj: str = ...,
check_dtype: bool | Literal["equiv"] = True,
index_values: Index | np.ndarray | None = None,
check_exact: bool = False,
rtol: float = 1e-5,
atol: float = 1e-8,
obj: str = "ExtensionArray",
) -> None: ...
@overload
def assert_series_equal(
Expand Down Expand Up @@ -151,21 +151,21 @@ def assert_series_equal(
def assert_frame_equal(
left: DataFrame,
right: DataFrame,
check_dtype: bool | Literal["equiv"] = ...,
check_index_type: bool | Literal["equiv"] = ...,
check_column_type: bool | Literal["equiv"] = ...,
check_frame_type: bool = ...,
check_names: bool = ...,
by_blocks: bool = ...,
check_exact: bool = ...,
check_datetimelike_compat: bool = ...,
check_categorical: bool = ...,
check_like: bool = ...,
check_freq: bool = ...,
check_flags: bool = ...,
rtol: float = ...,
atol: float = ...,
obj: str = ...,
check_dtype: bool | Literal["equiv"] = True,
check_index_type: bool | Literal["equiv"] = "equiv",
check_column_type: bool | Literal["equiv"] = "equiv",
check_frame_type: bool = True,
check_names: bool = True,
by_blocks: bool = False,
check_exact: bool = False,
check_datetimelike_compat: bool = False,
check_categorical: bool = True,
check_like: bool = False,
check_freq: bool = True,
check_flags: bool = True,
rtol: float = 1e-5,
atol: float = 1e-8,
obj: str = "DataFrame",
) -> None: ...
def assert_equal(left, right, **kwargs) -> None: ...
def assert_sp_array_equal(left: SparseArray, right: SparseArray) -> None: ...
Expand All @@ -178,12 +178,12 @@ def assert_produces_warning(
) = ...,
filter_level: Literal[
"error", "ignore", "always", "default", "module", "once"
] = ...,
check_stacklevel: bool = ...,
raise_on_extra_warnings: bool = ...,
] = "always",
check_stacklevel: bool = True,
raise_on_extra_warnings: bool = True,
match: str | None = None,
) -> Generator[list[warnings.WarningMessage], None, None]: ...
@contextmanager
def ensure_clean(
filename: str | None = ..., return_filelike: bool = ..., **kwargs: Any
filename: str | None = None, return_filelike: bool = False, **kwargs: Any
) -> Generator[str, None, None]: ...
10 changes: 5 additions & 5 deletions pandas-stubs/core/algorithms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def factorize(
) -> tuple[np.ndarray, Categorical]: ...
def value_counts(
values: AnyArrayLike | list | tuple,
sort: bool = ...,
ascending: bool = ...,
normalize: bool = ...,
bins: int | None = ...,
dropna: bool = ...,
sort: bool = True,
ascending: bool = False,
normalize: bool = False,
bins: int | None = None,
dropna: bool = True,
) -> Series: ...
def take(
arr,
Expand Down
12 changes: 6 additions & 6 deletions pandas-stubs/core/arrays/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ExtensionArray:
def to_numpy(
self,
dtype: npt.DTypeLike | None = ...,
copy: bool = ...,
copy: bool = False,
na_value: Scalar = ...,
) -> np.ndarray: ...
@property
Expand All @@ -40,17 +40,17 @@ class ExtensionArray:
def ndim(self) -> int: ...
@property
def nbytes(self) -> int: ...
def astype(self, dtype, copy: bool = ...): ...
def astype(self, dtype, copy: bool = True): ...
def isna(self) -> ArrayLike: ...
def argsort(
self, *, ascending: bool = ..., kind: str = ..., **kwargs
) -> np.ndarray: ...
def fillna(self, value=..., method=..., limit=...): ...
def fillna(self, value=..., method=None, limit=None): ...
def dropna(self): ...
def shift(self, periods: int = ..., fill_value: object = ...) -> Self: ...
def shift(self, periods: int = 1, fill_value: object = ...) -> Self: ...
def unique(self): ...
def searchsorted(self, value, side: str = ..., sorter=...): ...
def factorize(self, use_na_sentinel: bool = ...) -> tuple[np.ndarray, Self]: ...
def factorize(self, use_na_sentinel: bool = True) -> tuple[np.ndarray, Self]: ...
def repeat(self, repeats, axis=...): ...
def take(
self,
Expand All @@ -61,7 +61,7 @@ class ExtensionArray:
) -> Self: ...
def copy(self) -> Self: ...
def view(self, dtype=...) -> Self | np.ndarray: ...
def ravel(self, order=...) -> Self: ...
def ravel(self, order="C") -> Self: ...
def tolist(self) -> list: ...
def _reduce(
self, name: str, *, skipna: bool = ..., keepdims: bool = ..., **kwargs
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/arrays/boolean.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ class BooleanArray(BaseMaskedArray):
def dtype(self): ...
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...
def __setitem__(self, key, value) -> None: ...
def astype(self, dtype, copy: bool = ...): ...
def astype(self, dtype, copy: bool = True): ...
def any(self, *, skipna: bool = ..., **kwargs): ...
def all(self, *, skipna: bool = ..., **kwargs): ...
Loading
Loading