Add typing annotation to assert_index_equal
State: closed

-  xref #26302 
- passes `git diff upstream/master -u -- "*.py" | flake8 --diff`



Labels:
name: Typing
description: type annotations, mypy/pyright type checking

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=h1) Report
> Merging [#26535](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0a516c15dcb4b3b6eae8bc231a5c8656acfca5b4?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26535/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26535      +/-   ##
==========================================
- Coverage   91.76%   91.76%   -0.01%     
==========================================
  Files         174      174              
  Lines       50629    50631       +2     
==========================================
- Hits        46462    46461       -1     
- Misses       4167     4170       +3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (ø)` | :arrow_up: |
| #single | `41.71% <100%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26535/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.72% <100%> (+0.12%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26535/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26535/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=footer). Last update [0a516c1...453875e](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=h1) Report
> Merging [#26535](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cf25c5cd3ab1f647f780167df622c74b737fa8f5?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26535/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26535      +/-   ##
==========================================
- Coverage   91.78%   91.77%   -0.01%     
==========================================
  Files         174      174              
  Lines       50703    50706       +3     
==========================================
- Hits        46538    46537       -1     
- Misses       4165     4169       +4
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.37% <100%> (ø)` | :arrow_up: |
| #single | `41.81% <100%> (-0.09%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26535/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.63% <100%> (+0.02%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26535/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26535/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.88% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=footer). Last update [cf25c5c...de3fbf2](https://codecov.io/gh/pandas-dev/pandas/pull/26535?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

https://github.com/pandas-dev/pandas/blob/19f693fa70d77c4d52b7ba6eba3afa1496cde605/mypy.ini#L5-L6

`pandas/conftest` and `pandas/tests` are excluded. The `assert_*_equal` are in `pandas/util`, mypy has been checking these assertion functions.
After removing `pandas.tests.*` only in `mypy.ini`, the following is mypy error:

```
pandas/tests/test_base.py:1232: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/test_base.py:1266: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/tseries/offsets/test_offsets_properties.py:43: error: Argument "min_value" to "datetimes" has incompatible type "Tuple[Any]"; expected "datetime"
pandas/tests/tseries/offsets/test_offsets_properties.py:43: error: Argument "max_value" to "datetimes" has incompatible type "Tuple[Any]"; expected "datetime"
pandas/tests/series/test_constructors.py:38: error: Need type annotation for 'x'
pandas/tests/series/test_constructors.py:43: error: Need type annotation for 'x'
pandas/tests/scalar/timestamp/test_rendering.py:14: error: Module has no attribute "__version__"
pandas/tests/io/test_sql.py:884: error: Incompatible types in assignment (expression has type "str", base class "_TestSQLApi" defined the type as "None")
pandas/tests/io/test_sql.py:1074: error: Incompatible types in assignment (expression has type "str", base class "_TestSQLApi" defined the type as "None")
pandas/tests/io/test_sql.py:1965: error: Definition of "flavor" in base class "_TestMySQLAlchemy" is incompatible with definition in base class "_TestSQLAlchemy"
pandas/tests/io/test_sql.py:1971: error: Definition of "flavor" in base class "_TestMySQLAlchemy" is incompatible with definition in base class "_TestSQLAlchemy"
pandas/tests/io/test_sql.py:1977: error: Definition of "flavor" in base class "_TestPostgreSQLAlchemy" is incompatible with definition in base class "_TestSQLAlchemy"
pandas/tests/io/test_sql.py:1983: error: Definition of "flavor" in base class "_TestPostgreSQLAlchemy" is incompatible with definition in base class "_TestSQLAlchemy"
pandas/tests/io/test_sql.py:1989: error: Definition of "flavor" in base class "_TestSQLiteAlchemy" is incompatible with definition in base class "_TestSQLAlchemy"
pandas/tests/io/test_sql.py:1994: error: Definition of "flavor" in base class "_TestSQLiteAlchemy" is incompatible with definition in base class "_TestSQLAlchemy"
pandas/tests/io/parser/conftest.py:11: error: Need type annotation for 'float_precision_choices'
pandas/tests/io/parser/conftest.py:30: error: Incompatible types in assignment (expression has type "str", base class "BaseParser" defined the type as "None")
pandas/tests/io/parser/conftest.py:43: error: Incompatible types in assignment (expression has type "str", base class "BaseParser" defined the type as "None")
pandas/tests/io/parser/conftest.py:63: error: Unsupported operand types for + ("List[CParser]" and "List[PythonParser]")
pandas/tests/io/json/test_ujson.py:4: error: Name 'json' already defined (by an import)
pandas/tests/io/formats/test_to_csv.py:320: error: Unexpected keyword argument "levels" for "MultiIndex"
pandas/tests/io/formats/test_to_csv.py:320: error: Unexpected keyword argument "codes" for "MultiIndex"
pandas/tests/io/formats/test_to_csv.py:320: error: Unexpected keyword argument "names" for "MultiIndex"
pandas/tests/io/formats/test_to_csv.py:324: error: Unexpected keyword argument "levels" for "MultiIndex"
pandas/tests/io/formats/test_to_csv.py:324: error: Unexpected keyword argument "codes" for "MultiIndex"
pandas/tests/io/formats/test_to_csv.py:324: error: Unexpected keyword argument "names" for "MultiIndex"
pandas/tests/indexing/test_coercion.py:802: error: List item 0 has incompatible type "int"; expected "str"
pandas/tests/indexing/test_coercion.py:802: error: List item 1 has incompatible type "int"; expected "str"
pandas/tests/indexing/test_coercion.py:803: error: List item 0 has incompatible type "float"; expected "str"
pandas/tests/indexing/test_coercion.py:803: error: List item 1 has incompatible type "float"; expected "str"
pandas/tests/indexing/test_coercion.py:804: error: List item 0 has incompatible type "complex"; expected "str"
pandas/tests/indexing/test_coercion.py:804: error: List item 1 has incompatible type "complex"; expected "str"
pandas/tests/indexing/test_coercion.py:805: error: List item 0 has incompatible type "bool"; expected "str"
pandas/tests/indexing/test_coercion.py:805: error: List item 1 has incompatible type "bool"; expected "str"
pandas/tests/indexes/interval/test_interval_tree.py:146: error: Argument 1 to "map" has incompatible type "Type[List[Any]]"; expected "Callable[[Tuple[int, ...]], List[_T]]"
pandas/tests/indexes/interval/test_interval_tree.py:153: error: Argument 1 to "map" has incompatible type "Type[List[Any]]"; expected "Callable[[Tuple[int, ...]], List[_T]]"
pandas/tests/extension/json/array.py:30: error: Need type annotation for 'na_value'
pandas/tests/arrays/test_period.py:239: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/arrays/test_datetimelike.py:228: error: Incompatible types in assignment (expression has type "Type[DatetimeIndex]", base class "SharedTests" defined the type as "None")
pandas/tests/arrays/test_datetimelike.py:468: error: Incompatible types in assignment (expression has type "Type[TimedeltaIndex]", base class "SharedTests" defined the type as "None")
pandas/tests/arrays/test_datetimelike.py:578: error: Incompatible types in assignment (expression has type "Type[PeriodIndex]", base class "SharedTests" defined the type as "None")
pandas/tests/arrays/sparse/test_arithmetics.py:429: error: Incompatible types in assignment (expression has type "Type[SparseSeries]", base class "TestSparseArrayArithmetics" defined the type as "Type[SparseArray]")
pandas/tests/arithmetic/test_datetime64.py:2080: error: "DatetimeIndex" has no attribute "tz_localize"
pandas/tests/test_algos.py:730: error: Invalid signature "def (self: Any) -> Any"
pandas/tests/tseries/offsets/test_offsets.py:589: error: Incompatible types in assignment (expression has type "Type[BusinessDay]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:678: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[BusinessDay, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:693: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[BusinessDay, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:747: error: Incompatible types in assignment (expression has type "Type[BusinessHour]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:1429: error: Incompatible types in assignment (expression has type "Type[CustomBusinessHour]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:1672: error: Incompatible types in assignment (expression has type "Type[CustomBusinessDay]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:1764: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[CustomBusinessDay, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:1779: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[CustomBusinessDay, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:1922: error: Incompatible types in assignment (expression has type "Type[CustomBusinessMonthEnd]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:1978: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[CustomBusinessMonthEnd, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:1986: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[CustomBusinessMonthEnd, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:2039: error: Incompatible types in assignment (expression has type "Type[CustomBusinessMonthBegin]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:2095: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[CustomBusinessMonthBegin, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:2103: error: Argument 1 to "append" of "list" has incompatible type "Tuple[int, Dict[datetime, datetime]]"; expected "Tuple[CustomBusinessMonthBegin, Dict[datetime, datetime]]"
pandas/tests/tseries/offsets/test_offsets.py:2156: error: Incompatible types in assignment (expression has type "Type[Week]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:2231: error: Incompatible types in assignment (expression has type "Type[WeekOfMonth]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:2332: error: Incompatible types in assignment (expression has type "Type[LastWeekOfMonth]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:2409: error: Incompatible types in assignment (expression has type "Type[SemiMonthEnd]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_offsets.py:2596: error: Incompatible types in assignment (expression has type "Type[SemiMonthBegin]", base class "Base" defined the type as "None")
pandas/tests/series/test_operators.py:694: error: "Type[Series]" has no attribute "div"
pandas/tests/series/test_operators.py:695: error: "Type[Series]" has no attribute "rdiv"
pandas/tests/indexing/test_loc.py:527: error: No overload variant of "slice" matches argument types "None", "str", "None"
pandas/tests/indexing/test_loc.py:527: note: Possible overload variant:
pandas/tests/indexing/test_loc.py:527: note:     def slice(self, start: Optional[int], stop: Optional[int], step: Optional[int] = ...) -> slice
pandas/tests/indexing/test_loc.py:527: note:     <1 more non-matching overload not shown>
pandas/tests/indexes/test_numeric.py:96: error: Incompatible types in assignment (expression has type "Type[Float64Index]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_numeric.py:584: error: Incompatible types in assignment (expression has type "Type[Int64Index]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_numeric.py:872: error: Incompatible types in assignment (expression has type "Type[UInt64Index]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_category.py:20: error: Incompatible types in assignment (expression has type "Type[CategoricalIndex]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_base.py:34: error: Incompatible types in assignment (expression has type "Type[Index]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_base.py:452: error: Need type annotation for 'x'
pandas/tests/indexes/test_base.py:464: error: Need type annotation for 'x'
pandas/tests/indexes/test_base.py:466: error: Unexpected keyword argument "levels" for "MultiIndex"
pandas/tests/indexes/test_base.py:466: error: Unexpected keyword argument "codes" for "MultiIndex"
pandas/tests/indexes/test_base.py:1593: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1594: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1595: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1596: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1598: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1599: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1600: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1601: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:1602: error: Slice index must be an integer or None
pandas/tests/indexes/test_base.py:2164: error: Incompatible types in assignment (expression has type "Type[Index]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_base.py:2417: error: Too many arguments for "MultiIndex"
pandas/tests/indexes/test_base.py:2419: error: Too many arguments for "MultiIndex"
pandas/tests/indexes/test_base.py:2419: error: Unexpected keyword argument "names" for "MultiIndex"
pandas/tests/indexes/interval/test_interval.py:22: error: Incompatible types in assignment (expression has type "Type[IntervalIndex]", base class "Base" defined the type as "None")
pandas/tests/indexes/datetimes/test_tools.py:200: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:204: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:208: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:210: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:214: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:216: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:1816: error: Module has no attribute "FixedOffset"
pandas/tests/indexes/datetimes/test_tools.py:1818: error: Module has no attribute "FixedOffset"
pandas/tests/frame/test_convert_to.py:488: error: Argument 1 to "defaultdict" has incompatible type "Type[List[Any]]"; expected "Optional[Callable[[], Dict[str, float]]]"
pandas/tests/frame/test_constructors.py:35: error: Need type annotation for 'x'
pandas/tests/frame/test_constructors.py:41: error: Need type annotation for 'x'
pandas/tests/frame/test_constructors.py:54: error: Need type annotation for 'x'
pandas/tests/dtypes/test_inference.py:56: error: Need type annotation for 'x'
pandas/tests/dtypes/test_inference.py:239: error: Too many arguments for "tuple"
pandas/tests/dtypes/test_inference.py:239: error: Argument 1 to "tuple" has incompatible type "int"; expected "Iterable[Any]"
pandas/tests/computation/test_eval.py:1808: error: Dict entry 1 has incompatible type "str": "Type[ExprVisitor]"; expected "str": "Type[BaseExprVisitor]"
pandas/tests/api/test_api.py:33: error: Need type annotation for 'deprecated_modules'
pandas/tests/api/test_api.py:56: error: Need type annotation for 'deprecated_classes_in_future'
pandas/tests/api/test_api.py:90: error: Need type annotation for 'deprecated_funcs_in_future'
pandas/tests/api/test_api.py:93: error: Need type annotation for 'deprecated_funcs'
pandas/tests/tseries/offsets/test_yqm_offsets.py:386: error: Incompatible types in assignment (expression has type "Type[QuarterEnd]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:502: error: Incompatible types in assignment (expression has type "Type[BQuarterBegin]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:597: error: Incompatible types in assignment (expression has type "Type[BQuarterEnd]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:712: error: Incompatible types in assignment (expression has type "Type[YearBegin]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:804: error: Incompatible types in assignment (expression has type "Type[YearEnd]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:901: error: Incompatible types in assignment (expression has type "Type[BYearBegin]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:950: error: Incompatible types in assignment (expression has type "Type[BYearEnd]", base class "Base" defined the type as "None")
pandas/tests/tseries/offsets/test_yqm_offsets.py:997: error: Incompatible types in assignment (expression has type "Type[BYearEnd]", base class "Base" defined the type as "None")
pandas/tests/indexes/test_range.py:20: error: Incompatible types in assignment (expression has type "Type[RangeIndex]", base class "Base" defined the type as "None")
pandas/tests/indexes/timedeltas/test_timedelta.py:21: error: Incompatible types in assignment (expression has type "Type[TimedeltaIndex]", base class "Base" defined the type as "None")
pandas/tests/indexes/period/test_period.py:17: error: Incompatible types in assignment (expression has type "Type[PeriodIndex]", base class "Base" defined the type as "None")
pandas/tests/indexes/datetimes/test_datetimelike.py:10: error: Incompatible types in assignment (expression has type "Type[DatetimeIndex]", base class "Base" defined the type as "None")
pandas/tests/dtypes/test_common.py:295: error: Unsupported operand types for + ("List[Series]" and "List[str]")
pandas/tests/dtypes/test_common.py:312: error: Unsupported operand types for + ("List[Series]" and "List[object]")
pandas/tests/dtypes/test_common.py:334: error: Unsupported operand types for + ("List[Series]" and "List[str]")
pandas/tests/arrays/test_array.py:32: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/arrays/test_array.py:36: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/arrays/test_array.py:99: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/arrays/test_array.py:129: error: Argument "freq" to "period_array" has incompatible type "str"; expected "Optional[Tick]"
pandas/tests/extension/test_sparse.py:305: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_sparse.py:306: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_sparse.py:307: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_sparse.py:308: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_numpy.py:263: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_numpy.py:264: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_numpy.py:265: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/test_numpy.py:266: error: Incompatible types in assignment (expression has type "None", base class "BaseArithmeticOpsTests" defined the type as "Type[TypeError]")
pandas/tests/extension/json/test_json.py:108: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:108: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:112: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:112: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:131: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:131: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:139: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:139: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:156: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:156: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:160: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:160: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:179: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:179: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:235: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:235: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:248: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:248: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:277: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:277: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:295: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:295: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:299: error: Definition of "assert_series_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/json/test_json.py:299: error: Definition of "assert_frame_equal" in base class "BaseJSON" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:115: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:115: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:120: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:120: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:124: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:124: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:132: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:132: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:136: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:136: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:148: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:148: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:174: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:174: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:190: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:190: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:194: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:194: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:198: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:198: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:202: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:202: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:262: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:262: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:297: error: Definition of "assert_series_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
pandas/tests/extension/decimal/test_decimal.py:297: error: Definition of "assert_frame_equal" in base class "BaseDecimal" is incompatible with definition in base class "BaseExtensionTests"
```
@WillAyd Would you tell me more? I don't understand what you mean.
There is not type check for MultiIndex before. Removing one of the MultiIndex checks would result in mypy error.
There is a cast function in the standard typing module you can use

Sent from my iPhone

> On Jun 2, 2019, at 10:42 AM, Mak Sze Chun <notifications@github.com> wrote:
> 
> @makbigc commented on this pull request.
> 
> In pandas/util/testing.py:
> 
> > @@ -587,19 +593,20 @@ def _get_ilevel_values(index, level):
>          raise_assert_detail(obj, msg1, msg2, msg3)
>  
>      # MultiIndex special comparison for little-friendly error messages
> -    if left.nlevels > 1:
> -        for level in range(left.nlevels):
> -            # cannot use get_level_values here because it can change dtype
> -            llevel = _get_ilevel_values(left, level)
> -            rlevel = _get_ilevel_values(right, level)
> -
> -            lobj = 'MultiIndex level [{level}]'.format(level=level)
> -            assert_index_equal(llevel, rlevel,
> -                               exact=exact, check_names=check_names,
> -                               check_less_precise=check_less_precise,
> -                               check_exact=check_exact, obj=lobj)
> -            # get_level_values may change dtype
> -            _check_types(left.levels[level], right.levels[level], obj=obj)
> +    if isinstance(left, MultiIndex) and isinstance(right, MultiIndex):
> +        if left.nlevels > 1:
> Pardon me. I am not familiar with casting in Python. By casting, do you mean left = MuliIndex(left)? This is a construction of a new MuliIndex which result in type error in our case TypeError: Must pass both levels and labels.
> 
> Or one more type annotation?
> 
> left  # type: MultiIndex
> right  # type: MultiIndex
> _check_types(left.levels[level], right.levels[level], obj=obj)
> mypy still regards left and right as Index.
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

Something wrong with CI. Travis test can't be finished.
@WillAyd All tests passed.
thanks @makbigc very nice!