Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions pandas-stubs/core/indexes/interval.pyi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can verify that the changes correctly correspond to https://pandas.pydata.org/docs/dev/reference/api/pandas.interval_range.html.

Original file line number Diff line number Diff line change
Expand Up @@ -295,57 +295,57 @@ class IntervalIndex(ExtensionIndex[IntervalT, np.object_], IntervalMixin):
# int gets hit first and so the correct type is returned
@overload
def interval_range( # pyright: ignore[reportOverlappingOverload]
start: int | None = ...,
end: int | None = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
start: int | None = None,
end: int | None = None,
periods: int | None = None,
freq: int | None = None,
name: Hashable = None,
closed: IntervalClosedType = "right",
) -> IntervalIndex[Interval[int]]: ...
@overload
def interval_range(
start: float | None = ...,
end: float | None = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
start: float | None = None,
end: float | None = None,
periods: int | None = None,
freq: int | None = None,
name: Hashable = None,
closed: IntervalClosedType = "right",
) -> IntervalIndex[Interval[float]]: ...
@overload
def interval_range(
start: _TimestampLike,
end: _TimestampLike | None = ...,
periods: int | None = ...,
freq: Frequency | dt.timedelta | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
end: _TimestampLike | None = None,
periods: int | None = None,
freq: Frequency | dt.timedelta | None = None,
name: Hashable = None,
closed: IntervalClosedType = "right",
) -> IntervalIndex[Interval[pd.Timestamp]]: ...
@overload
def interval_range(
*,
start: None = None,
Comment on lines 325 to 326
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be the following?

Suggested change
*,
start: None = None,
start: None = None,
*,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this overload is meant to force the user to pass start, same for the one you also commented on.
It will work at least from the tests that I have run, I have pushed, let me know if you want to revert.

end: _TimestampLike,
periods: int | None = ...,
freq: Frequency | dt.timedelta | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
periods: int | None = None,
freq: Frequency | dt.timedelta | None = None,
name: Hashable = None,
closed: IntervalClosedType = "right",
) -> IntervalIndex[Interval[pd.Timestamp]]: ...
@overload
def interval_range(
start: _TimedeltaLike,
end: _TimedeltaLike | None = ...,
periods: int | None = ...,
freq: Frequency | dt.timedelta | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
end: _TimedeltaLike | None = None,
periods: int | None = None,
freq: Frequency | dt.timedelta | None = None,
name: Hashable = None,
closed: IntervalClosedType = "right",
) -> IntervalIndex[Interval[pd.Timedelta]]: ...
@overload
def interval_range(
*,
start: None = None,
Comment on lines 344 to 345
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be the following?

Suggested change
*,
start: None = None,
start: None = None,
*,

end: _TimedeltaLike,
periods: int | None = ...,
freq: Frequency | dt.timedelta | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
periods: int | None = None,
freq: Frequency | dt.timedelta | None = None,
name: Hashable = None,
closed: IntervalClosedType = "right",
) -> IntervalIndex[Interval[pd.Timedelta]]: ...
Loading