Skip to content

Commit 2128b2a

Browse files
jbrockmendeljreback
authored andcommitted
annotations (#30724)
1 parent 0bbfa0a commit 2128b2a

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

pandas/_libs/interval.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ cdef class Interval(IntervalMixin):
326326
def __hash__(self):
327327
return hash((self.left, self.right, self.closed))
328328

329-
def __contains__(self, key):
329+
def __contains__(self, key) -> bool:
330330
if _interval_like(key):
331331
raise TypeError("__contains__ not defined for two intervals")
332332
return ((self.left < key if self.open_left else self.left <= key) and

pandas/core/arrays/categorical.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ def __iter__(self):
18741874
"""
18751875
return iter(self._internal_get_values().tolist())
18761876

1877-
def __contains__(self, key):
1877+
def __contains__(self, key) -> bool:
18781878
"""
18791879
Returns True if `key` is in this Categorical.
18801880
"""
@@ -1884,7 +1884,7 @@ def __contains__(self, key):
18841884

18851885
return contains(self, key, container=self._codes)
18861886

1887-
def _tidy_repr(self, max_vals=10, footer=True):
1887+
def _tidy_repr(self, max_vals=10, footer=True) -> str:
18881888
""" a short repr displaying only max_vals and an optional (but default
18891889
footer)
18901890
"""
@@ -1921,7 +1921,7 @@ def _repr_categories(self):
19211921
category_strs = [x.strip() for x in category_strs]
19221922
return category_strs
19231923

1924-
def _repr_categories_info(self):
1924+
def _repr_categories_info(self) -> str:
19251925
"""
19261926
Returns a string representation of the footer.
19271927
"""
@@ -1951,11 +1951,11 @@ def _repr_categories_info(self):
19511951
# replace to simple save space by
19521952
return levheader + "[" + levstring.replace(" < ... < ", " ... ") + "]"
19531953

1954-
def _repr_footer(self):
1954+
def _repr_footer(self) -> str:
19551955
info = self._repr_categories_info()
19561956
return f"Length: {len(self)}\n{info}"
19571957

1958-
def _get_repr(self, length=True, na_rep="NaN", footer=True):
1958+
def _get_repr(self, length=True, na_rep="NaN", footer=True) -> str:
19591959
from pandas.io.formats import format as fmt
19601960

19611961
formatter = fmt.CategoricalFormatter(

pandas/core/indexes/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __array_wrap__(self, result, context=None):
147147

148148
# ------------------------------------------------------------------------
149149

150-
def equals(self, other):
150+
def equals(self, other) -> bool:
151151
"""
152152
Determines if two Index objects contain the same elements.
153153
"""

pandas/core/internals/managers.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -738,16 +738,16 @@ def combine(self, blocks, copy=True):
738738

739739
return type(self)(new_blocks, axes, do_integrity_check=False)
740740

741-
def get_slice(self, slobj, axis=0):
741+
def get_slice(self, slobj: slice, axis: int = 0):
742742
if axis >= self.ndim:
743743
raise IndexError("Requested axis not found in manager")
744744

745745
if axis == 0:
746746
new_blocks = self._slice_take_blocks_ax0(slobj)
747747
else:
748-
slicer = [slice(None)] * (axis + 1)
749-
slicer[axis] = slobj
750-
slicer = tuple(slicer)
748+
_slicer = [slice(None)] * (axis + 1)
749+
_slicer[axis] = slobj
750+
slicer = tuple(_slicer)
751751
new_blocks = [blk.getitem_block(slicer) for blk in self.blocks]
752752

753753
new_axes = list(self.axes)
@@ -757,11 +757,11 @@ def get_slice(self, slobj, axis=0):
757757
bm._consolidate_inplace()
758758
return bm
759759

760-
def __contains__(self, item):
760+
def __contains__(self, item) -> bool:
761761
return item in self.items
762762

763763
@property
764-
def nblocks(self):
764+
def nblocks(self) -> int:
765765
return len(self.blocks)
766766

767767
def copy(self, deep=True):

pandas/plotting/_misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def __delitem__(self, key):
453453
raise ValueError(f"Cannot remove default parameter {key}")
454454
return super().__delitem__(key)
455455

456-
def __contains__(self, key):
456+
def __contains__(self, key) -> bool:
457457
key = self._get_canonical_key(key)
458458
return super().__contains__(key)
459459

pandas/tests/dtypes/test_inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def __getitem__(self, key):
240240

241241
if has_contains:
242242

243-
def __contains__(self, key):
243+
def __contains__(self, key) -> bool:
244244
return self.d.__contains__(key)
245245

246246
d = DictLike({1: 2})

pandas/tests/frame/methods/test_to_records.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def __init__(self, **kwargs):
326326
def __getitem__(self, key):
327327
return self.d.__getitem__(key)
328328

329-
def __contains__(self, key):
329+
def __contains__(self, key) -> bool:
330330
return key in self.d
331331

332332
def keys(self):

0 commit comments

Comments
 (0)