Skip to content

CLN: disallow kind=None in _convert_slice_indexer #31832

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
Feb 9, 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
6 changes: 3 additions & 3 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3152,7 +3152,7 @@ def _validate_positional_slice(self, key: slice):
self._validate_indexer("positional", key.stop, "iloc")
self._validate_indexer("positional", key.step, "iloc")

def _convert_slice_indexer(self, key: slice, kind=None):
def _convert_slice_indexer(self, key: slice, kind: str_t):
"""
Convert a slice indexer.

Expand All @@ -3162,9 +3162,9 @@ def _convert_slice_indexer(self, key: slice, kind=None):
Parameters
----------
key : label of the slice bound
kind : {'loc', 'getitem'} or None
kind : {'loc', 'getitem'}
"""
assert kind in ["loc", "getitem", None], kind
assert kind in ["loc", "getitem"], kind

# potentially cast the bounds to integers
start, stop, step = key.start, key.stop, key.step
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def get_indexer_for(self, target: AnyArrayLike, **kwargs) -> np.ndarray:
return self.get_indexer_non_unique(target)[0]
return self.get_indexer(target, **kwargs)

def _convert_slice_indexer(self, key: slice, kind=None):
def _convert_slice_indexer(self, key: slice, kind: str):
if not (key.step is None or key.step == 1):
raise ValueError("cannot support not-default step in a slice")
return super()._convert_slice_indexer(key, kind)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ def _convert_scalar_indexer(self, key, kind: str):
return key

@Appender(Index._convert_slice_indexer.__doc__)
def _convert_slice_indexer(self, key: slice, kind=None):
assert kind in ["loc", "getitem", None]
def _convert_slice_indexer(self, key: slice, kind: str):
assert kind in ["loc", "getitem"]

# We always treat __getitem__ slicing as label-based
# translate to locations
Expand Down
3 changes: 0 additions & 3 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,6 @@ def _setitem_with_indexer(self, indexer, value):
value = getattr(value, "values", value).ravel()

# we can directly set the series here
# as we select a slice indexer on the mi
if isinstance(idx, slice):
idx = index._convert_slice_indexer(idx)
obj._consolidate_inplace()
obj = obj.copy()
obj._data = obj._data.setitem(indexer=tuple([idx]), value=value)
Expand Down