-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
builtins.slice
: more precise __new__
overloads and let StopT
default to StartT
.
#12904
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
builtins.slice
: more precise __new__
overloads and let StopT
default to StartT
.
#12904
Conversation
Co-authored-by: Alex Waygood <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
builtins.slice
: more precise __new__
overloads and let StopT
default to StartT
.
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.
Looks promising!
This comment has been minimized.
This comment has been minimized.
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.
Nice! Looks like you now just need to update some assertions in the test-case file to use Union[int, Any]
rather than Any
in order to make the test case pass.
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Alex Waygood <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
One doubt I have is whether we should change it so that Without this convention, describing the most commonly used slice type, which I think is slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None] Probably requires an alias since it is so long. Moreover, I think we need to clarify whether the |
@AlexWaygood #13008 is the same as this, but defaults A decision needs to be made between:
|
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Closing in favor of #13008. |
Different overloads than #12899, testing mypy primer.
check_slice.py
stubtest, testing bothslice.__new__
constructor andslice[T]
annotationStopT
to default toStartT
instead ofAny
. For example:slice[int] = slice[int, int, Any]
represents finite intervalsslice[int | None] = slice[int | None, int | None, Any]
arbitrary intervals__new__
, removed special casing forint
types.slice.__new__
now follows a very simply rule: anyNone
argument will result in the corresponding Generic Type to be considered asAny
.