ruff/crates/ruff_linter/src
Auguste Lalande 0c194f55e8
Fix PT014 autofix for last item in list (#10532)
## Summary

This error was found browsing
8396966850.
Which failed when trying to autofix the PT014 violation in the following
code:
```python
@pytest.mark.parametrize('data, spec', [(1.0, 1.0), (1.0, 1.0)])
def test_numbers(data, spec):
    ...
```

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,

0a99bd84ce/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs (L647-L651)
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.
2024-03-23 09:26:42 -04:00
..
checkers Correctly handle references in __all__ definitions when renaming symbols in autofixes (#10527) 2024-03-22 20:06:35 +00:00
comments Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
cst Wrap expressions in parentheses when negating (#10346) 2024-03-11 18:20:55 -04:00
docstrings [pydocstyle-D405] Allow using parameters as a sub-section header (#9894) 2024-02-08 21:54:32 -05:00
fix Update Rust to v1.77 (#10510) 2024-03-21 12:10:33 -04:00
importer Update Rust to v1.77 (#10510) 2024-03-21 12:10:33 -04:00
lex Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
message Feature: Add SARIF output support (#9078) 2023-12-13 00:33:19 -05:00
registry --show-settings displays active settings in a far more readable format (#9464) 2024-01-12 14:30:29 -05:00
rules Fix PT014 autofix for last item in list (#10532) 2024-03-23 09:26:42 -04:00
settings Remove F401 fix for __init__ imports by default and allow opt-in to unsafe fix (#10365) 2024-03-13 12:58:25 -05:00
snapshots Detect automagic-like assignments in notebooks (#9653) 2024-01-29 12:55:44 +00:00
codes.rs Rename list-reassign-reversed to list-reverse-copy (#10514) 2024-03-21 17:33:00 +00:00
directives.rs Track quoting style in the tokenizer (#10256) 2024-03-08 08:40:06 +00:00
doc_lines.rs Split Constant to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
fs.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
lib.rs Rename Autofix to Fix (#7657) 2023-09-28 10:53:05 +00:00
line_width.rs --show-settings displays active settings in a far more readable format (#9464) 2024-01-12 14:30:29 -05:00
linter.rs [pycodestyle] Implement redundant-backslash (E502) (#10292) 2024-03-11 21:15:06 -04:00
logging.rs Make --config and --isolated global flags (#10150) 2024-03-04 11:19:40 +00:00
noqa.rs Respect external codes in file-level exemptions (#10203) 2024-03-03 00:20:36 +00:00
packaging.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
pyproject_toml.rs Update pyproject-toml to 0.8 (#8351) 2023-10-30 10:05:37 +00:00
registry.rs [pycodestyle] Implement blank-line-at-end-of-file (W391) (#10243) 2024-03-11 22:07:59 -04:00
renamer.rs Correctly handle references in __all__ definitions when renaming symbols in autofixes (#10527) 2024-03-22 20:06:35 +00:00
rule_redirects.rs Bump version to 0.2.0 (#9762) 2024-02-01 17:10:33 -06:00
rule_selector.rs Fix clippy unused variable warning (#9902) 2024-02-08 22:13:31 +00:00
source_kind.rs CLI: Color entire line in Diffs (#10183) 2024-03-01 13:53:45 +01:00
test.rs Update Rust to v1.77 (#10510) 2024-03-21 12:10:33 -04:00
upstream_categories.rs Fix pylint upstream categories not showing in docs (#10441) 2024-03-18 01:27:39 +00:00