Skip to content

MultiIndex(MutableSequence[tuple]) should not work #1499

@cmp0xff

Description

@cmp0xff

Describe the bug

Currently MultiIndex([MutableSequence[tuple]) is recognised as working, which is not true at runtime.

To Reproduce

Provide a minimal runnable pandas example

from typing import reveal_type
import pandas as pd
from collections import UserList, deque

data = [(1,), (2,)]

reveal_type(pd.MultiIndex(data)) # runtime: TypeError: Must pass both levels and codes
reveal_type(pd.MultiIndex(UserList(data)))  # runtime: TypeError: Must pass both levels and codes
reveal_type(pd.MultiIndex(deque(data)))  # runtime: TypeError: Must pass both levels and codes

Indicate which type checker you are using

both

Show the error message received from that type checker while checking your example.

No error message from the type checker, which does not reflect the fact that the example does not work at runtime.

Please complete the following information:

  • OS: Windows
  • OS Version: 11
  • python version: 3.14
  • version of type checker: mypy 1.18.2, pyright 1.1.407
  • version of installed pandas-stubs: 5a47589

Additional context

We need to fix MultiIndex.__new__.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions