Skip to content

Make slice generic #11637

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

Merged
merged 19 commits into from
Oct 24, 2024
Merged
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
24 changes: 18 additions & 6 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from _typeshed import (
ConvertibleToFloat,
ConvertibleToInt,
FileDescriptorOrPath,
MaybeNone,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
Expand Down Expand Up @@ -94,6 +95,9 @@ _SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant
_AwaitableT = TypeVar("_AwaitableT", bound=Awaitable[Any])
_AwaitableT_co = TypeVar("_AwaitableT_co", bound=Awaitable[Any], covariant=True)
_P = ParamSpec("_P")
_StartT = TypeVar("_StartT", covariant=True, default=Any)
_StopT = TypeVar("_StopT", covariant=True, default=Any)
_StepT = TypeVar("_StepT", covariant=True, default=Any)

class object:
__doc__: str | None
Expand Down Expand Up @@ -936,17 +940,25 @@ class bool(int):
def __invert__(self) -> int: ...

@final
class slice:
class slice(Generic[_StartT, _StopT, _StepT]):
@property
def start(self) -> Any: ...
def start(self) -> _StartT: ...
@property
def step(self) -> Any: ...
def step(self) -> _StepT: ...
@property
def stop(self) -> Any: ...
def stop(self) -> _StopT: ...
@overload
def __new__(cls, stop: Any, /) -> Self: ...
def __new__(cls, stop: int | None) -> slice[int | MaybeNone, int | MaybeNone, int | MaybeNone]: ...
@overload
def __new__(cls, start: Any, stop: Any, step: Any = ..., /) -> Self: ...
def __new__(
cls, start: int | None, stop: int | None, step: int | None = None
) -> slice[int | MaybeNone, int | MaybeNone, int | MaybeNone]: ...
@overload
def __new__(cls, stop: _T2, /) -> slice[Any, _T2, Any]: ...
@overload
def __new__(cls, start: _T1, stop: _T2, /) -> slice[_T1, _T2, Any]: ...
@overload
def __new__(cls, start: _T1, stop: _T2, step: _T3, /) -> slice[_T1, _T2, _T3]: ...
def __eq__(self, value: object, /) -> bool: ...
if sys.version_info >= (3, 12):
def __hash__(self) -> int: ...
Expand Down
Loading