Fix PT014
autofix for last item in list
#10532
Merged
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.
Summary
This error was found browsing https://github.com/qarmin/Automated-Fuzzer/actions/runs/8396966850. Which failed when trying to autofix the PT014 violation in the following code:
Investigation revealed that the implementation was not properly tested, when the duplicate value was also the last in the list. In particular the following function, which is in charge of finding the comma following an element to create the suggested fix,
ruff/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs
Lines 647 to 651 in 0a99bd8
would find the next comma even if it was outside the list itself leading to a lot of code being deleted.
This PR fixes that.
Test Plan
Added misbehaving code to the test fixture.