Skip to content

Commit f93f9f3

Browse files
committed
add some -> to pandas core
1 parent 27135a5 commit f93f9f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+127
-123
lines changed

pandas/core/array_algos/replace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def compare_or_regex_search(
6767

6868
def _check_comparison_types(
6969
result: ArrayLike | bool, a: ArrayLike, b: Scalar | Pattern
70-
):
70+
) -> None:
7171
"""
7272
Raises an error if the two arrays (a,b) cannot be compared.
7373
Otherwise, returns the comparison result as expected.

pandas/core/array_algos/take.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def _get_take_nd_function(
337337

338338
if func is None:
339339

340-
def func(arr, indexer, out, fill_value=np.nan):
340+
def func(arr, indexer, out, fill_value=np.nan) -> None:
341341
indexer = ensure_platform_int(indexer)
342342
_take_nd_object(
343343
arr, indexer, out, axis=axis, fill_value=fill_value, mask_info=mask_info
@@ -349,7 +349,7 @@ def func(arr, indexer, out, fill_value=np.nan):
349349
def _view_wrapper(f, arr_dtype=None, out_dtype=None, fill_wrap=None):
350350
def wrapper(
351351
arr: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=np.nan
352-
):
352+
) -> None:
353353
if arr_dtype is not None:
354354
arr = arr.view(arr_dtype)
355355
if out_dtype is not None:
@@ -364,7 +364,7 @@ def wrapper(
364364
def _convert_wrapper(f, conv_dtype):
365365
def wrapper(
366366
arr: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=np.nan
367-
):
367+
) -> None:
368368
if conv_dtype == object:
369369
# GH#39755 avoid casting dt64/td64 to integers
370370
arr = ensure_wrapped_if_datetimelike(arr)
@@ -506,7 +506,7 @@ def _take_nd_object(
506506
axis: int,
507507
fill_value,
508508
mask_info,
509-
):
509+
) -> None:
510510
if mask_info is not None:
511511
mask, needs_masking = mask_info
512512
else:

pandas/core/arrays/_mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def _validate_shift_value(self, fill_value):
259259
# we can remove this and use validate_fill_value directly
260260
return self._validate_scalar(fill_value)
261261

262-
def __setitem__(self, key, value):
262+
def __setitem__(self, key, value) -> None:
263263
key = check_array_indexer(self, key)
264264
value = self._validate_setitem_value(value)
265265
self._ndarray[key] = value

pandas/core/arrays/arrow/_arrow_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pandas.core.arrays.interval import VALID_CLOSED
1515

1616

17-
def fallback_performancewarning(version: str | None = None):
17+
def fallback_performancewarning(version: str | None = None) -> None:
1818
"""
1919
Raise a PerformanceWarning for falling back to ExtensionArray's
2020
non-pyarrow method

pandas/core/arrays/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ def _create_arithmetic_method(cls, op):
16561656
raise AbstractMethodError(cls)
16571657

16581658
@classmethod
1659-
def _add_arithmetic_ops(cls):
1659+
def _add_arithmetic_ops(cls) -> None:
16601660
setattr(cls, "__add__", cls._create_arithmetic_method(operator.add))
16611661
setattr(cls, "__radd__", cls._create_arithmetic_method(roperator.radd))
16621662
setattr(cls, "__sub__", cls._create_arithmetic_method(operator.sub))
@@ -1681,7 +1681,7 @@ def _create_comparison_method(cls, op):
16811681
raise AbstractMethodError(cls)
16821682

16831683
@classmethod
1684-
def _add_comparison_ops(cls):
1684+
def _add_comparison_ops(cls) -> None:
16851685
setattr(cls, "__eq__", cls._create_comparison_method(operator.eq))
16861686
setattr(cls, "__ne__", cls._create_comparison_method(operator.ne))
16871687
setattr(cls, "__lt__", cls._create_comparison_method(operator.lt))
@@ -1694,7 +1694,7 @@ def _create_logical_method(cls, op):
16941694
raise AbstractMethodError(cls)
16951695

16961696
@classmethod
1697-
def _add_logical_ops(cls):
1697+
def _add_logical_ops(cls) -> None:
16981698
setattr(cls, "__and__", cls._create_logical_method(operator.and_))
16991699
setattr(cls, "__rand__", cls._create_logical_method(roperator.rand_))
17001700
setattr(cls, "__or__", cls._create_logical_method(operator.or_))

pandas/core/arrays/categorical.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def categories(self):
738738
return self.dtype.categories
739739

740740
@categories.setter
741-
def categories(self, categories):
741+
def categories(self, categories) -> None:
742742
new_dtype = CategoricalDtype(categories, ordered=self.ordered)
743743
if self.dtype.categories is not None and len(self.dtype.categories) != len(
744744
new_dtype.categories
@@ -776,7 +776,7 @@ def codes(self) -> np.ndarray:
776776
v.flags.writeable = False
777777
return v
778778

779-
def _set_categories(self, categories, fastpath=False):
779+
def _set_categories(self, categories, fastpath=False) -> None:
780780
"""
781781
Sets new categories inplace
782782
@@ -1700,7 +1700,7 @@ def _internal_get_values(self):
17001700
return self.categories.astype("object").take(self._codes, fill_value=np.nan)
17011701
return np.array(self)
17021702

1703-
def check_for_ordered(self, op):
1703+
def check_for_ordered(self, op) -> None:
17041704
"""assert that we are ordered"""
17051705
if not self.ordered:
17061706
raise TypeError(
@@ -1931,7 +1931,7 @@ def _codes(self) -> np.ndarray:
19311931
return self._ndarray
19321932

19331933
@_codes.setter
1934-
def _codes(self, value: np.ndarray):
1934+
def _codes(self, value: np.ndarray) -> None:
19351935
warn(
19361936
"Setting the codes on a Categorical is deprecated and will raise in "
19371937
"a future version. Create a new Categorical object instead",
@@ -1985,7 +1985,7 @@ def __contains__(self, key) -> bool:
19851985
# ------------------------------------------------------------------
19861986
# Rendering Methods
19871987

1988-
def _formatter(self, boxed: bool = False):
1988+
def _formatter(self, boxed: bool = False) -> None:
19891989
# Defer to CategoricalFormatter's formatter.
19901990
return None
19911991

@@ -2713,7 +2713,7 @@ def __init__(self, data) -> None:
27132713
self._freeze()
27142714

27152715
@staticmethod
2716-
def _validate(data):
2716+
def _validate(data) -> None:
27172717
if not is_categorical_dtype(data.dtype):
27182718
raise AttributeError("Can only use .cat accessor with a 'category' dtype")
27192719

pandas/core/arrays/datetimelike.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def __setitem__( # type: ignore[override]
410410

411411
self._maybe_clear_freq()
412412

413-
def _maybe_clear_freq(self):
413+
def _maybe_clear_freq(self) -> None:
414414
# inplace operations like __setitem__ may invalidate the freq of
415415
# DatetimeArray and TimedeltaArray
416416
pass
@@ -924,7 +924,7 @@ def freq(self):
924924
return self._freq
925925

926926
@freq.setter
927-
def freq(self, value):
927+
def freq(self, value) -> None:
928928
if value is not None:
929929
value = to_offset(value)
930930
self._validate_frequency(self, value)
@@ -976,7 +976,7 @@ def resolution(self) -> str:
976976
return self._resolution_obj.attrname # type: ignore[union-attr]
977977

978978
@classmethod
979-
def _validate_frequency(cls, index, freq, **kwargs):
979+
def _validate_frequency(cls, index, freq, **kwargs) -> None:
980980
"""
981981
Validate that a frequency is compatible with the values of a given
982982
Datetime Array/Index or Timedelta Array/Index

pandas/core/arrays/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def _unbox_scalar(self, value, setitem: bool = False) -> np.datetime64:
520520
def _scalar_from_string(self, value) -> Timestamp | NaTType:
521521
return Timestamp(value, tz=self.tz)
522522

523-
def _check_compatible_with(self, other, setitem: bool = False):
523+
def _check_compatible_with(self, other, setitem: bool = False) -> None:
524524
if other is NaT:
525525
return
526526
self._assert_tzawareness_compat(other)

pandas/core/arrays/interval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def from_tuples(
598598

599599
return cls.from_arrays(left, right, inclusive, copy=False, dtype=dtype)
600600

601-
def _validate(self):
601+
def _validate(self) -> None:
602602
"""
603603
Verify that the IntervalArray is valid.
604604
@@ -692,7 +692,7 @@ def __getitem__(
692692
raise ValueError("multi-dimensional indexing not allowed")
693693
return self._shallow_copy(left, right)
694694

695-
def __setitem__(self, key, value):
695+
def __setitem__(self, key, value) -> None:
696696
value_left, value_right = self._validate_setitem_value(value)
697697
key = check_array_indexer(self, key)
698698

pandas/core/arrays/period.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def _unbox_scalar( # type: ignore[override]
336336
def _scalar_from_string(self, value: str) -> Period:
337337
return Period(value, freq=self.freq)
338338

339-
def _check_compatible_with(self, other, setitem: bool = False):
339+
def _check_compatible_with(self, other, setitem: bool = False) -> None:
340340
if other is NaT:
341341
return
342342
self._require_matching_freq(other)

0 commit comments

Comments
 (0)