@@ -242,7 +242,7 @@ def _has_valid_tuple(self, key: Tuple):
242
242
"[{types}] types" .format (types = self ._valid_types )
243
243
)
244
244
245
- def _is_nested_tuple_indexer (self , tup : Tuple ):
245
+ def _is_nested_tuple_indexer (self , tup : Tuple ) -> bool :
246
246
if any (isinstance (ax , ABCMultiIndex ) for ax in self .obj .axes ):
247
247
return any (is_nested_tuple (tup , ax ) for ax in self .obj .axes )
248
248
return False
@@ -275,10 +275,10 @@ def _convert_slice_indexer(self, key: slice, axis: int):
275
275
ax = self .obj ._get_axis (min (axis , self .ndim - 1 ))
276
276
return ax ._convert_slice_indexer (key , kind = self .name )
277
277
278
- def _has_valid_setitem_indexer (self , indexer ):
278
+ def _has_valid_setitem_indexer (self , indexer ) -> bool :
279
279
return True
280
280
281
- def _has_valid_positional_setitem_indexer (self , indexer ):
281
+ def _has_valid_positional_setitem_indexer (self , indexer ) -> bool :
282
282
""" validate that an positional indexer cannot enlarge its target
283
283
will raise if needed, does not modify the indexer externally
284
284
"""
@@ -1314,7 +1314,7 @@ def __init__(self, name, obj):
1314
1314
super ().__init__ (name , obj )
1315
1315
1316
1316
@Appender (_NDFrameIndexer ._validate_key .__doc__ )
1317
- def _validate_key (self , key , axis : int ):
1317
+ def _validate_key (self , key , axis : int ) -> bool :
1318
1318
if isinstance (key , slice ):
1319
1319
return True
1320
1320
@@ -1685,7 +1685,7 @@ def _validate_key(self, key, axis: int):
1685
1685
if not is_list_like_indexer (key ):
1686
1686
self ._convert_scalar_indexer (key , axis )
1687
1687
1688
- def _is_scalar_access (self , key : Tuple ):
1688
+ def _is_scalar_access (self , key : Tuple ) -> bool :
1689
1689
# this is a shortcut accessor to both .loc and .iloc
1690
1690
# that provide the equivalent access of .at and .iat
1691
1691
# a) avoid getting things via sections and (to minimize dtype changes)
@@ -1998,7 +1998,7 @@ def _validate_key(self, key, axis: int):
1998
1998
def _has_valid_setitem_indexer (self , indexer ):
1999
1999
self ._has_valid_positional_setitem_indexer (indexer )
2000
2000
2001
- def _is_scalar_access (self , key : Tuple ):
2001
+ def _is_scalar_access (self , key : Tuple ) -> bool :
2002
2002
# this is a shortcut accessor to both .loc and .iloc
2003
2003
# that provide the equivalent access of .at and .iat
2004
2004
# a) avoid getting things via sections and (to minimize dtype changes)
@@ -2022,7 +2022,7 @@ def _getitem_scalar(self, key):
2022
2022
values = self .obj ._get_value (* key , takeable = True )
2023
2023
return values
2024
2024
2025
- def _validate_integer (self , key : int , axis : int ):
2025
+ def _validate_integer (self , key : int , axis : int ) -> None :
2026
2026
"""
2027
2027
Check that 'key' is a valid position in the desired axis.
2028
2028
@@ -2448,7 +2448,7 @@ def maybe_convert_ix(*args):
2448
2448
return args
2449
2449
2450
2450
2451
- def is_nested_tuple (tup , labels ):
2451
+ def is_nested_tuple (tup , labels ) -> bool :
2452
2452
# check for a compatible nested tuple and multiindexes among the axes
2453
2453
if not isinstance (tup , tuple ):
2454
2454
return False
@@ -2461,12 +2461,12 @@ def is_nested_tuple(tup, labels):
2461
2461
return False
2462
2462
2463
2463
2464
- def is_label_like (key ):
2464
+ def is_label_like (key ) -> bool :
2465
2465
# select a label or row
2466
2466
return not isinstance (key , slice ) and not is_list_like_indexer (key )
2467
2467
2468
2468
2469
- def need_slice (obj ):
2469
+ def need_slice (obj ) -> bool :
2470
2470
return (
2471
2471
obj .start is not None
2472
2472
or obj .stop is not None
@@ -2487,7 +2487,7 @@ def _non_reducing_slice(slice_):
2487
2487
if isinstance (slice_ , kinds ):
2488
2488
slice_ = IndexSlice [:, slice_ ]
2489
2489
2490
- def pred (part ):
2490
+ def pred (part ) -> bool :
2491
2491
# true when slice does *not* reduce, False when part is a tuple,
2492
2492
# i.e. MultiIndex slice
2493
2493
return (isinstance (part , slice ) or is_list_like (part )) and not isinstance (
@@ -2519,7 +2519,7 @@ def _maybe_numeric_slice(df, slice_, include_bool=False):
2519
2519
return slice_
2520
2520
2521
2521
2522
- def _can_do_equal_len (labels , value , plane_indexer , lplane_indexer , obj ):
2522
+ def _can_do_equal_len (labels , value , plane_indexer , lplane_indexer , obj ) -> bool :
2523
2523
""" return True if we have an equal len settable """
2524
2524
if not len (labels ) == 1 or not np .iterable (value ) or is_scalar (plane_indexer [0 ]):
2525
2525
return False
0 commit comments