Skip to content

Commit c865eec

Browse files
makbigcjreback
authored andcommitted
Add typing annotation to assert_index_equal (#26535)
1 parent caed313 commit c865eec

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pandas/util/testing.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import string
1313
import tempfile
1414
import traceback
15+
from typing import Union, cast
1516
import warnings
1617
import zipfile
1718

@@ -515,9 +516,14 @@ def equalContents(arr1, arr2):
515516
return frozenset(arr1) == frozenset(arr2)
516517

517518

518-
def assert_index_equal(left, right, exact='equiv', check_names=True,
519-
check_less_precise=False, check_exact=True,
520-
check_categorical=True, obj='Index'):
519+
def assert_index_equal(left: Index,
520+
right: Index,
521+
exact: Union[bool, str] = 'equiv',
522+
check_names: bool = True,
523+
check_less_precise: Union[bool, int] = False,
524+
check_exact: bool = True,
525+
check_categorical: bool = True,
526+
obj: str = 'Index') -> None:
521527
"""Check that left and right Index are equal.
522528
523529
Parameters
@@ -588,6 +594,9 @@ def _get_ilevel_values(index, level):
588594

589595
# MultiIndex special comparison for little-friendly error messages
590596
if left.nlevels > 1:
597+
left = cast(MultiIndex, left)
598+
right = cast(MultiIndex, right)
599+
591600
for level in range(left.nlevels):
592601
# cannot use get_level_values here because it can change dtype
593602
llevel = _get_ilevel_values(left, level)

0 commit comments

Comments
 (0)