Skip to content

MultiIndex.from_product should accept range objects #1285

@neutrinonerd3333

Description

@neutrinonerd3333

Describe the bug
range objects supplied to the Cartesian product of MultiIndex.from_product should pass type checking:

import pandas as pd

mi = pd.MultiIndex.from_product(
    [range(3), range(5)],
)

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs. see above.
  2. Indicate which type checker you are using (mypy or pyright). mypy.
  3. Show the error message received from that type checker while checking your example.

List item 0 has incompatible type "range"; expected "SequenceNotStr[Hashable] | Series[Any] | Index[Any]"
(ditto for item 1)

(but it would appear that range objects should be viewable as SequenceNotStr[int])

Please complete the following information:

  • OS: Windows 10 Pro, 10.0.19045
  • python 3.12
  • version of type checker: mypy 1.15.0 (via "Mypy Type Checker" extension in VSCode)
  • version of installed pandas-stubs: 2.3.0.250703

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions