Skip to content

Various Index operators missing #405

Closed
@adamchainz

Description

@adamchainz

Describe the bug
I discovered that Index.__rpow__ is missing when trying to lint my code.

To Reproduce

import pandas

df = pandas.DataFrame({"nums": [1, 2]})
print(2**df.index)

Runs:

$ python example.py
0    2
1    4
Name: nums, dtype: int64

But Mypy not happy:

$ pre-commit run mypy --file example.py
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

example.py:4: error: No overload variant of "__pow__" of "int" matches argument type "Index"  [operator]
example.py:4: note: Possible overload variants:
example.py:4: note:     def __pow__(self, Literal[0]) -> Literal[1]
example.py:4: note:     def __pow__(self, Literal[0], None) -> Literal[1]
example.py:4: note:     def __pow__(self, Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], None = ...) -> int
example.py:4: note:     def __pow__(self, Literal[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20], None = ...) -> float
example.py:4: note:     def __pow__(self, int, None = ...) -> Any
example.py:4: note:     def __pow__(self, int, Literal[0]) -> NoReturn
example.py:4: note:     def __pow__(self, int, int) -> int
Found 1 error in 1 file (checked 1 source file)

It seems that various dunder funcs on Index are missing.

Please complete the following information:

  • OS: macOS
  • OS Version 12
  • python version: 3.10
  • version of type checker: 0.982
  • version of installed pandas-stubs: 1.5.1.221024

Additional context
n/a

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