From dcf9ddb391bc1d2a81f8371811e9e18a50aa77ea Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:19:39 +0000 Subject: [PATCH 1/2] use strict typing for tslibs/nattype and tslibs/dtypes --- pandas-stubs/_libs/tslibs/dtypes.pyi | 2 +- pandas-stubs/_libs/tslibs/nattype.pyi | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pandas-stubs/_libs/tslibs/dtypes.pyi b/pandas-stubs/_libs/tslibs/dtypes.pyi index 7d0a43ab2..68e132d95 100644 --- a/pandas-stubs/_libs/tslibs/dtypes.pyi +++ b/pandas-stubs/_libs/tslibs/dtypes.pyi @@ -5,7 +5,7 @@ from .offsets import BaseOffset class PeriodDtypeBase: def __init__(self, code: int) -> None: ... - def __eq__(self, other) -> bool: ... + def __eq__(self, other: object) -> bool: ... @property def date_offset(self) -> BaseOffset: ... @classmethod diff --git a/pandas-stubs/_libs/tslibs/nattype.pyi b/pandas-stubs/_libs/tslibs/nattype.pyi index cc74db157..40f745497 100644 --- a/pandas-stubs/_libs/tslibs/nattype.pyi +++ b/pandas-stubs/_libs/tslibs/nattype.pyi @@ -1,3 +1,4 @@ +# pyright: strict from datetime import ( datetime, timedelta, @@ -11,7 +12,10 @@ from typing_extensions import ( ) from pandas._libs.tslibs.period import Period -from pandas._typing import TimeUnit +from pandas._typing import ( + NpDtype, + TimeUnit, +) NaT: NaTType iNaT: int @@ -30,7 +34,7 @@ class NaTType: def asm8(self) -> np.datetime64: ... def to_datetime64(self) -> np.datetime64: ... def to_numpy( - self, dtype: np.dtype | str | None = ..., copy: bool = ... + self, dtype: NpDtype | None = ..., copy: bool = ... ) -> np.datetime64 | np.timedelta64: ... @property def is_leap_year(self) -> bool: ... @@ -67,8 +71,8 @@ class NaTType: def weekday(self) -> float: ... def isoweekday(self) -> float: ... def total_seconds(self) -> float: ... - def today(self, *args, **kwargs) -> NaTType: ... - def now(self, *args, **kwargs) -> NaTType: ... + def today(self, tz: _tzinfo | str | None = ...) -> NaTType: ... + def now(self, tz: _tzinfo | str | None = ...) -> NaTType: ... def to_pydatetime(self) -> NaTType: ... def date(self) -> NaTType: ... def round(self) -> NaTType: ... From 4ccb3c69787cbcd371f2976e18ee9e161a4d6d7e Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Tue, 11 Mar 2025 11:33:22 +0000 Subject: [PATCH 2/2] remove unused --- pandas-stubs/_libs/tslibs/dtypes.pyi | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 pandas-stubs/_libs/tslibs/dtypes.pyi diff --git a/pandas-stubs/_libs/tslibs/dtypes.pyi b/pandas-stubs/_libs/tslibs/dtypes.pyi deleted file mode 100644 index f5eabbf88..000000000 --- a/pandas-stubs/_libs/tslibs/dtypes.pyi +++ /dev/null @@ -1,27 +0,0 @@ -from .offsets import BaseOffset - -class PeriodDtypeBase: - def __init__(self, code: int) -> None: ... - def __eq__(self, other: object) -> bool: ... - @property - def date_offset(self) -> BaseOffset: ... - @classmethod - def from_date_offset(cls, offset: BaseOffset) -> PeriodDtypeBase: ... - -class FreqGroup: - FR_ANN: int - FR_QTR: int - FR_MTH: int - FR_WK: int - FR_BUS: int - FR_DAY: int - FR_HR: int - FR_MIN: int - FR_SEC: int - FR_MS: int - FR_US: int - FR_NS: int - FR_UND: int - - @staticmethod - def get_freq_group(code: int) -> int: ...