pandas-stubs icon indicating copy to clipboard operation
pandas-stubs copied to clipboard

`pd.RangeIndex` should accept `range` as the first argument

Open Daverball opened this issue 2 years ago • 2 comments

Describe the bug Both according to the docs and the implementation it is valid to pass a python range object as the first argument to pd.RangeIndex

To Reproduce

import pandas as pd

pd.RangeIndex(range(5))  # mypy: arg-type – Argument 1 to "RangeIndex" has incompatible type "range"

Please complete the following information:

  • OS: Linux (OpenSUSE Tumbleweed)
  • Python 3.10
  • mypy 1.0.1
  • pandas-stubs 2.0.1.230501

Daverball avatar May 03 '23 07:05 Daverball

Would need to add range here https://github.com/pandas-dev/pandas-stubs/blob/9c301b33b746e28401868b788364cecd00a34655/pandas-stubs/core/indexes/range.pyi#L30 (and probably also for __new__)

twoertwein avatar May 05 '23 13:05 twoertwein

(and probably also for __new__)

We actually don't need __new__() here, so we should delete it.

Dr-Irv avatar May 05 '23 23:05 Dr-Irv