Skip to content

Commit f873fb9

Browse files
jbrockmendelsimonjayhawkins
authored andcommitted
TYP: annotations (#31115)
1 parent a890239 commit f873fb9

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

pandas/core/indexes/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4566,7 +4566,7 @@ def shift(self, periods=1, freq=None):
45664566
"""
45674567
raise NotImplementedError(f"Not supported for type {type(self).__name__}")
45684568

4569-
def argsort(self, *args, **kwargs):
4569+
def argsort(self, *args, **kwargs) -> np.ndarray:
45704570
"""
45714571
Return the integer indices that would sort the index.
45724572
@@ -5052,7 +5052,7 @@ def _searchsorted_monotonic(self, label, side="left"):
50525052

50535053
raise ValueError("index must be monotonic increasing or decreasing")
50545054

5055-
def get_slice_bound(self, label, side, kind):
5055+
def get_slice_bound(self, label, side, kind) -> int:
50565056
"""
50575057
Calculate slice bound that corresponds to given label.
50585058
@@ -5217,7 +5217,7 @@ def delete(self, loc):
52175217
"""
52185218
return self._shallow_copy(np.delete(self._data, loc))
52195219

5220-
def insert(self, loc, item):
5220+
def insert(self, loc: int, item):
52215221
"""
52225222
Make new Index inserting new item at location.
52235223

pandas/core/indexes/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def delete(self, loc):
798798
"""
799799
return self._create_from_codes(np.delete(self.codes, loc))
800800

801-
def insert(self, loc, item):
801+
def insert(self, loc: int, item):
802802
"""
803803
Make new Index inserting new item at location. Follows
804804
Python list.append semantics for negative values

pandas/core/indexes/interval.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def is_unique(self):
468468
return True
469469

470470
@property
471-
def is_overlapping(self):
471+
def is_overlapping(self) -> bool:
472472
"""
473473
Return True if the IntervalIndex has overlapping intervals, else False.
474474
@@ -562,7 +562,7 @@ def _can_reindex(self, indexer: np.ndarray) -> None:
562562
if self.is_overlapping and len(indexer):
563563
raise ValueError("cannot reindex from an overlapping axis")
564564

565-
def _needs_i8_conversion(self, key):
565+
def _needs_i8_conversion(self, key) -> bool:
566566
"""
567567
Check if a given key needs i8 conversion. Conversion is necessary for
568568
Timestamp, Timedelta, DatetimeIndex, and TimedeltaIndex keys. An
@@ -1036,7 +1036,7 @@ def _format_space(self) -> str:
10361036

10371037
# --------------------------------------------------------------------
10381038

1039-
def argsort(self, *args, **kwargs):
1039+
def argsort(self, *args, **kwargs) -> np.ndarray:
10401040
return np.lexsort((self.right, self.left))
10411041

10421042
def equals(self, other) -> bool:

pandas/core/indexes/multi.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ def append(self, other):
20132013
except (TypeError, IndexError):
20142014
return Index(new_tuples)
20152015

2016-
def argsort(self, *args, **kwargs):
2016+
def argsort(self, *args, **kwargs) -> np.ndarray:
20172017
return self.values.argsort(*args, **kwargs)
20182018

20192019
@Appender(_index_shared_docs["repeat"] % _index_doc_kwargs)
@@ -3135,7 +3135,7 @@ def equals(self, other) -> bool:
31353135

31363136
return True
31373137

3138-
def equal_levels(self, other):
3138+
def equal_levels(self, other) -> bool:
31393139
"""
31403140
Return True if the levels of both MultiIndex objects are the same
31413141
@@ -3335,7 +3335,7 @@ def _convert_can_do_setop(self, other):
33353335
result_names = self.names if self.names == other.names else None
33363336
return other, result_names
33373337

3338-
def insert(self, loc, item):
3338+
def insert(self, loc: int, item):
33393339
"""
33403340
Make new MultiIndex inserting new item at location
33413341

pandas/core/indexes/numeric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def is_all_dates(self) -> bool:
160160
return False
161161

162162
@Appender(Index.insert.__doc__)
163-
def insert(self, loc, item):
163+
def insert(self, loc: int, item):
164164
# treat NA values as nans:
165165
if is_scalar(item) and isna(item):
166166
item = self._na_value

pandas/core/indexes/range.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
421421
nv.validate_max(args, kwargs)
422422
return self._minmax("max")
423423

424-
def argsort(self, *args, **kwargs):
424+
def argsort(self, *args, **kwargs) -> np.ndarray:
425425
"""
426426
Returns the indices that would sort the index and its
427427
underlying data.
@@ -441,7 +441,7 @@ def argsort(self, *args, **kwargs):
441441
else:
442442
return np.arange(len(self) - 1, -1, -1)
443443

444-
def equals(self, other):
444+
def equals(self, other) -> bool:
445445
"""
446446
Determines if two Index objects contain the same elements.
447447
"""

pandas/tseries/frequencies.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def is_unique(self) -> bool:
334334
return len(self.deltas) == 1
335335

336336
@cache_readonly
337-
def is_unique_asi8(self):
337+
def is_unique_asi8(self) -> bool:
338338
return len(self.deltas_asi8) == 1
339339

340340
def get_freq(self) -> Optional[str]:

0 commit comments

Comments
 (0)