Skip to content

Commit efd15b7

Browse files
authored
TYP: freq and na_value (#47729)
* TYP: freq and na_value * _simple_new
1 parent cf4758f commit efd15b7

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

pandas/core/arrays/datetimelike.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,9 @@ def validate_periods(periods: int | float | None) -> int | None:
22022202
return periods # type: ignore[return-value]
22032203

22042204

2205-
def validate_inferred_freq(freq, inferred_freq, freq_infer):
2205+
def validate_inferred_freq(
2206+
freq, inferred_freq, freq_infer
2207+
) -> tuple[BaseOffset | None, bool]:
22062208
"""
22072209
If the user passes a freq and another freq is inferred from passed data,
22082210
require that they match.

pandas/core/arrays/datetimes.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ def _validate_dtype(cls, values, dtype):
264264
# error: Signature of "_simple_new" incompatible with supertype "NDArrayBacked"
265265
@classmethod
266266
def _simple_new( # type: ignore[override]
267-
cls, values: np.ndarray, freq: BaseOffset | None = None, dtype=DT64NS_DTYPE
267+
cls,
268+
values: np.ndarray,
269+
freq: BaseOffset | None = None,
270+
dtype=DT64NS_DTYPE,
268271
) -> DatetimeArray:
269272
assert isinstance(values, np.ndarray)
270273
assert dtype.kind == "M"
@@ -291,7 +294,7 @@ def _from_sequence_not_strict(
291294
dtype=None,
292295
copy: bool = False,
293296
tz=None,
294-
freq=lib.no_default,
297+
freq: str | BaseOffset | lib.NoDefault | None = lib.no_default,
295298
dayfirst: bool = False,
296299
yearfirst: bool = False,
297300
ambiguous="raise",

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ def to_numpy(
17461746
self,
17471747
dtype: npt.DTypeLike | None = None,
17481748
copy: bool = False,
1749-
na_value=lib.no_default,
1749+
na_value: object = lib.no_default,
17501750
) -> np.ndarray:
17511751
"""
17521752
Convert the DataFrame to a NumPy array.

pandas/core/indexes/datetimes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
lib,
2626
)
2727
from pandas._libs.tslibs import (
28+
BaseOffset,
2829
Resolution,
2930
periods_per_day,
3031
timezones,
@@ -312,7 +313,7 @@ def isocalendar(self) -> DataFrame:
312313
def __new__(
313314
cls,
314315
data=None,
315-
freq=lib.no_default,
316+
freq: str | BaseOffset | lib.NoDefault = lib.no_default,
316317
tz=None,
317318
normalize: bool = False,
318319
closed=None,

pandas/core/internals/array_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ def as_array(
11321132
self,
11331133
dtype=None,
11341134
copy: bool = False,
1135-
na_value=lib.no_default,
1135+
na_value: object = lib.no_default,
11361136
) -> np.ndarray:
11371137
"""
11381138
Convert the blockmanager data into an numpy array.

0 commit comments

Comments
 (0)