diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 325c94d0ea267..c3fbd716ad09d 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -2202,7 +2202,9 @@ def validate_periods(periods: int | float | None) -> int | None: return periods # type: ignore[return-value] -def validate_inferred_freq(freq, inferred_freq, freq_infer): +def validate_inferred_freq( + freq, inferred_freq, freq_infer +) -> tuple[BaseOffset | None, bool]: """ If the user passes a freq and another freq is inferred from passed data, require that they match. diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index d9f6cecc8d61d..7a56bba0e58b3 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -264,7 +264,10 @@ def _validate_dtype(cls, values, dtype): # error: Signature of "_simple_new" incompatible with supertype "NDArrayBacked" @classmethod def _simple_new( # type: ignore[override] - cls, values: np.ndarray, freq: BaseOffset | None = None, dtype=DT64NS_DTYPE + cls, + values: np.ndarray, + freq: BaseOffset | None = None, + dtype=DT64NS_DTYPE, ) -> DatetimeArray: assert isinstance(values, np.ndarray) assert dtype.kind == "M" @@ -291,7 +294,7 @@ def _from_sequence_not_strict( dtype=None, copy: bool = False, tz=None, - freq=lib.no_default, + freq: str | BaseOffset | lib.NoDefault | None = lib.no_default, dayfirst: bool = False, yearfirst: bool = False, ambiguous="raise", diff --git a/pandas/core/frame.py b/pandas/core/frame.py index fe101926a6782..427c744b92a0a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1746,7 +1746,7 @@ def to_numpy( self, dtype: npt.DTypeLike | None = None, copy: bool = False, - na_value=lib.no_default, + na_value: object = lib.no_default, ) -> np.ndarray: """ Convert the DataFrame to a NumPy array. diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index f776585926024..3a7adb19f1c01 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -25,6 +25,7 @@ lib, ) from pandas._libs.tslibs import ( + BaseOffset, Resolution, periods_per_day, timezones, @@ -312,7 +313,7 @@ def isocalendar(self) -> DataFrame: def __new__( cls, data=None, - freq=lib.no_default, + freq: str | BaseOffset | lib.NoDefault = lib.no_default, tz=None, normalize: bool = False, closed=None, diff --git a/pandas/core/internals/array_manager.py b/pandas/core/internals/array_manager.py index 3a8ed54d6c634..88f81064b826f 100644 --- a/pandas/core/internals/array_manager.py +++ b/pandas/core/internals/array_manager.py @@ -1132,7 +1132,7 @@ def as_array( self, dtype=None, copy: bool = False, - na_value=lib.no_default, + na_value: object = lib.no_default, ) -> np.ndarray: """ Convert the blockmanager data into an numpy array.