Skip to content

Commit

Permalink
Make slice generic (#11637)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachaa-Thanasius authored Oct 24, 2024
1 parent 9ed47fa commit 65405e9
Showing 1 changed file with 18 additions and 6 deletions.
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

0 comments on commit 65405e9

Please sign in to comment.