-
-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Labels
IndexRelated to the Index class or subclassesRelated to the Index class or subclassesNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations
Description
Describe the bug
I think this is an issue:
def __sub__(self, other: Any) -> Self: ... |
as the dtype isn't preserved
To Reproduce
- Provide a minimal runnable
pandas
example that is not properly checked by the stubs. - Indicate which type checker you are using (
mypy
orpyright
). - Show the error message received from that type checker while checking your example.
from __future__ import annotations
import pandas as pd
from typing import reveal_type
idx = pd.Index([1,2,3])
reveal_type(idx - 1.5)
at runtime this gives
Index([-0.5, 0.5, 1.5], dtype='float64')
but it's revealed to be Index[int]
by type checkers
Please complete the following information:
- OS: [e.g. Windows, Linux, MacOS]
- OS Version [e.g. 22]
- python version
- version of type checker
- version of installed
pandas-stubs
3033eea
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
IndexRelated to the Index class or subclassesRelated to the Index class or subclassesNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations