Skip to content

WIP add some missing Optional type annotations #1315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
74 changes: 6 additions & 68 deletions pandas-stubs/core/indexes/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -310,59 +310,17 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
# int gets hit first and so the correct type is returned
@overload
def interval_range( # pyright: ignore[reportOverlappingOverload]
start: int = ...,
end: int = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[int]]: ...

# Overlaps since int is a subclass of float
@overload
def interval_range( # pyright: ignore[reportOverlappingOverload]
start: int,
*,
end: None = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[int]]: ...
@overload
def interval_range( # pyright: ignore[reportOverlappingOverload]
*,
start: None = ...,
end: int,
start: int | None = ...,
end: int | None = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[int]]: ...
@overload
def interval_range(
start: float = ...,
end: float = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[float]]: ...
@overload
def interval_range(
start: float,
*,
end: None = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[float]]: ...
@overload
def interval_range(
*,
start: None = ...,
end: float,
start: float | None = ...,
end: float | None = ...,
periods: int | None = ...,
freq: int | None = ...,
name: Hashable = ...,
Expand All @@ -371,7 +329,7 @@ def interval_range(
@overload
def interval_range(
start: _TimestampLike,
end: _TimestampLike = ...,
end: _TimestampLike | None = ...,
periods: int | None = ...,
freq: str | BaseOffset | pd.Timedelta | dt.timedelta | None = ...,
name: Hashable = ...,
Expand All @@ -388,19 +346,9 @@ def interval_range(
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[pd.Timestamp]]: ...
@overload
def interval_range(
start: _TimestampLike,
*,
end: None = ...,
periods: int | None = ...,
freq: str | BaseOffset | pd.Timedelta | dt.timedelta | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[pd.Timestamp]]: ...
@overload
def interval_range(
start: _TimedeltaLike,
end: _TimedeltaLike = ...,
end: _TimedeltaLike | None = ...,
periods: int | None = ...,
freq: str | BaseOffset | pd.Timedelta | dt.timedelta | None = ...,
name: Hashable = ...,
Expand All @@ -416,13 +364,3 @@ def interval_range(
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[pd.Timedelta]]: ...
@overload
def interval_range(
start: _TimedeltaLike,
*,
end: None = ...,
periods: int | None = ...,
freq: str | BaseOffset | pd.Timedelta | dt.timedelta | None = ...,
name: Hashable = ...,
closed: IntervalClosedType = ...,
) -> IntervalIndex[Interval[pd.Timedelta]]: ...
4 changes: 2 additions & 2 deletions pandas-stubs/io/sql.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def read_sql(
| None
) = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
columns: list[str] = ...,
columns: list[str] | 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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like #1293 missed the defaults for read_sql(). So can you make this columns: list[str] | None = None (and below as well)?

*,
chunksize: int,
dtype: DtypeArg | None = ...,
Expand All @@ -136,7 +136,7 @@ def read_sql(
| None
) = ...,
parse_dates: list[str] | dict[str, str] | dict[str, dict[str, Any]] | None = ...,
columns: list[str] = ...,
columns: list[str] | None = ...,
chunksize: None = ...,
dtype: DtypeArg | None = ...,
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
Expand Down
Loading