-
-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Description
Describe the bug
A clear and concise description of what the bug is.
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,)]
# runtime, all is MultiIndex
reveal_type(pd.Index(data)) # static: Index
reveal_type(pd.Index(UserList(data))) # static: Index
reveal_type(pd.Index(deque(data))) # static: not supportedIndicate which type checker you are using
both
Show the error message received from that type checker while checking your example.
mypy
ttest.py:8: note: Revealed type is "pandas.core.indexes.base.Index[Any]"
ttest.py:9: note: Revealed type is "pandas.core.indexes.base.Index[Any]"
ttest.py:10: note: Revealed type is "pandas.core.indexes.base.Index[builtins.bool]"
ttest.py:10: error: Argument 1 to "deque" has incompatible type "list[tuple[int]]"; expected "Iterable[builtins.bool | numpy.bool[builtins.bool]]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
pyright
ttest.py
ttest.py:8:13 - information: Type of "pd.Index(data)" is "Index[Any]"
ttest.py:9:13 - information: Type of "pd.Index(UserList(data))" is "Index[Any]"
ttest.py:10:13 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
ttest.py:10:13 - information: Type of "pd.Index(deque(data))" is "Index[Any]"
ttest.py:10:22 - error: Argument of type "deque[tuple[int]]" cannot be assigned to parameter "data" of type "AxesData[Unknown]" in function "__new__"
Type "deque[tuple[int]]" is not assignable to type "AxesData[Unknown]"
"deque[tuple[int]]" is not assignable to "Mapping[Unknown, Any]"
"deque[tuple[int]]" is not assignable to "ExtensionArray"
"deque[tuple[int]]" is not assignable to "ndarray[_AnyShape, dtype[Any]]"
"deque[tuple[int]]" is not assignable to "Index[Any]"
"deque[tuple[int]]" is not assignable to "Series[Any]"
"deque[tuple[int]]" is incompatible with protocol "SequenceNotStr[Any]"
"__getitem__" is an incompatible type
... (reportArgumentType)
ttest.py:10:22 - error: Argument of type "deque[tuple[int]]" cannot be assigned to parameter "data" of type "AxesData[Unknown]" in function "__new__"
Type "deque[tuple[int]]" is not assignable to type "AxesData[Unknown]"
"deque[tuple[int]]" is not assignable to "Mapping[Unknown, Any]"
"deque[tuple[int]]" is not assignable to "ExtensionArray"
"deque[tuple[int]]" is not assignable to "ndarray[_AnyShape, dtype[Any]]"
"deque[tuple[int]]" is not assignable to "Index[Any]"
"deque[tuple[int]]" is not assignable to "Series[Any]"
"deque[tuple[int]]" is incompatible with protocol "SequenceNotStr[Any]"
"__getitem__" is an incompatible type (reportArgumentType)
3 errors, 0 warnings, 3 informations
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 Index.__new__.
Metadata
Metadata
Assignees
Labels
No labels