-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Make slice() arguments optional #833
Conversation
…ather than just straight int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good improvement! Just some minutiae to take care of.
@@ -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: ... |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I wonder if the
|
From looking at this it seems to me adding |
I expect some issues with existing code needing new markup when we make it
generic, so I think we can go ahead with this intermediate version first.
|
OK, given that the 0 default value is ignored anyway, I'm just going to merge it. |
Thank you, @froomzy ✨ 🍰 ✨ |
Changed slice to take Optional[int] rather than just straight int. Fix for #832.