Skip to content

Make slice() arguments optional #833

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 1 commit into from
Jan 18, 2017
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
2 changes: 1 addition & 1 deletion stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class slice:
start = 0
step = 0
stop = 0
def __init__(self, start: int, stop: int = 0, step: int = 0) -> None: ...
def __init__(self, start: Optional[int], stop: Optional[int] = 0, step: Optional[int] = 0) -> None: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the step's default value to be None. In fact, it cannot be 0 :) Same for stop, the default value is None, behavior is different if 0 is given.

Copy link
Member

Choose a reason for hiding this comment

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

The default really should be ..., in stubs the value of the default is irrelevant, only its presence is used.

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 see how PyCharm could use actual defaults to help with auto-completion but yes, ... is indeed the canonical default value.


class tuple(Sequence[_T_co], Generic[_T_co]):
def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ...
Expand Down