Preserve omitted slice positions and validate builtin sequence slices#3942
Open
ak4-sh wants to merge 1 commit into
Open
Preserve omitted slice positions and validate builtin sequence slices#3942ak4-sh wants to merge 1 commit into
ak4-sh wants to merge 1 commit into
Conversation
Validate slice values for builtin sequences Add tests to check for correct slice behaviour Remove bug status from testcase since behaviour is fixed
|
Diff from mypy_primer, showing the effect of this PR on open source code: spark (https://github.com/apache/spark)
- ERROR python/pyspark/pandas/tests/test_typedef.py:190:37-53: Expected a type form, got instance of `slice[Literal['a'], type[float64], Literal['a'] | type[float64]]` [not-a-type]
+ ERROR python/pyspark/pandas/tests/test_typedef.py:190:37-53: Expected a type form, got instance of `slice[Literal['a'], type[float64], None]` [not-a-type]
- ERROR python/pyspark/pandas/tests/test_typedef.py:190:55-62: Expected a type form, got instance of `slice[Literal['b'], type[str], Literal['b'] | type[str]]` [not-a-type]
+ ERROR python/pyspark/pandas/tests/test_typedef.py:190:55-62: Expected a type form, got instance of `slice[Literal['b'], type[str], None]` [not-a-type]
- ERROR python/pyspark/pandas/tests/test_typedef.py:208:37-47: Expected a type form, got instance of `slice[Literal['a'], type[float], Literal['a'] | type[float]]` [not-a-type]
+ ERROR python/pyspark/pandas/tests/test_typedef.py:208:37-47: Expected a type form, got instance of `slice[Literal['a'], type[float], None]` [not-a-type]
- ERROR python/pyspark/pandas/tests/test_typedef.py:208:49-57: Expected a type form, got instance of `slice[Literal['b'], type[int], Literal['b'] | type[int]]` [not-a-type]
+ ERROR python/pyspark/pandas/tests/test_typedef.py:208:49-57: Expected a type form, got instance of `slice[Literal['b'], type[int], None]` [not-a-type]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validate slice values for builtin sequences
Add tests to check for correct slice behaviour
Remove bug status from testcase since behaviour is fixed
Summary
Validate slice components for builtin list and tuple subscripts. Pyrefly now reports errors for non-index slice values like decimal steps, and for literal zero steps. Also preserve omitted slice positions when inferring
slice[...]types so start, stop, and step do not shift into the wrong generic slots.Remove the
bugmarker from the existing zero-step slice test since the behaviour is now fixed, and add list/tuple coverage for decimal and zero step slices.Fixes #3768, #3896
Test Plan
cargo test test_slice_decimal_stepcargo test test_slice_zero_step