Skip to content

annotations #30724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ cdef class Interval(IntervalMixin):
def __hash__(self):
return hash((self.left, self.right, self.closed))

def __contains__(self, key):
def __contains__(self, key) -> bool:
if _interval_like(key):
raise TypeError("__contains__ not defined for two intervals")
return ((self.left < key if self.open_left else self.left <= key) and
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ def __iter__(self):
"""
return iter(self._internal_get_values().tolist())

def __contains__(self, key):
def __contains__(self, key) -> bool:
"""
Returns True if `key` is in this Categorical.
"""
Expand All @@ -1884,7 +1884,7 @@ def __contains__(self, key):

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

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

def _repr_categories_info(self):
def _repr_categories_info(self) -> str:
"""
Returns a string representation of the footer.
"""
Expand Down Expand Up @@ -1951,11 +1951,11 @@ def _repr_categories_info(self):
# replace to simple save space by
return levheader + "[" + levstring.replace(" < ... < ", " ... ") + "]"

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

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

formatter = fmt.CategoricalFormatter(
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __array_wrap__(self, result, context=None):

# ------------------------------------------------------------------------

def equals(self, other):
def equals(self, other) -> bool:
"""
Determines if two Index objects contain the same elements.
"""
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,16 +738,16 @@ def combine(self, blocks, copy=True):

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

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

if axis == 0:
new_blocks = self._slice_take_blocks_ax0(slobj)
else:
slicer = [slice(None)] * (axis + 1)
slicer[axis] = slobj
slicer = tuple(slicer)
_slicer = [slice(None)] * (axis + 1)
_slicer[axis] = slobj
slicer = tuple(_slicer)
new_blocks = [blk.getitem_block(slicer) for blk in self.blocks]

new_axes = list(self.axes)
Expand All @@ -757,11 +757,11 @@ def get_slice(self, slobj, axis=0):
bm._consolidate_inplace()
return bm

def __contains__(self, item):
def __contains__(self, item) -> bool:
return item in self.items

@property
def nblocks(self):
def nblocks(self) -> int:
return len(self.blocks)

def copy(self, deep=True):
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def __delitem__(self, key):
raise ValueError(f"Cannot remove default parameter {key}")
return super().__delitem__(key)

def __contains__(self, key):
def __contains__(self, key) -> bool:
key = self._get_canonical_key(key)
return super().__contains__(key)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def __getitem__(self, key):

if has_contains:

def __contains__(self, key):
def __contains__(self, key) -> bool:
return self.d.__contains__(key)

d = DictLike({1: 2})
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_to_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def __init__(self, **kwargs):
def __getitem__(self, key):
return self.d.__getitem__(key)

def __contains__(self, key):
def __contains__(self, key) -> bool:
return key in self.d

def keys(self):
Expand Down