pandas-dev / pandas-stubs

Public type stubs for pandas
BSD 3-Clause "New" or "Revised" License
234 stars 125 forks source link

GH677 Allow pd.RangeIndex to be initialized with range #1005

Closed loicdiridollou closed 1 month ago

loicdiridollou commented 1 month ago
loicdiridollou commented 1 month ago

/pandas_nightly

loicdiridollou commented 1 month ago

Happy to merge or wait if you want to remove __init__ first

I deleted the __init__ method, just waiting for CI to finish but it is looking ready from a code perspective.

twoertwein commented 1 month ago

Thanks @loicdiridollou !

Dr-Irv commented 1 month ago

FYI, I think we should have kept __init__() and deleted __new__(). In the stubs, we only need to have __new__() if we want to have different overloads that produce different results. Otherwise __init__() is sufficient.

Admittedly, we're inconsistent in the stubs about that. There are times we use __new__() instead of __init__()

twoertwein commented 1 month ago

Admittedly, we're inconsistent in the stubs about that. There are times we use __new__() instead of __init__()

If we want to become more stubtest compatible (aligning pandas and pandas-stubs), we should use which ever constructor pandas uses, at least when possible.