ruff
c69b19fe - [`flake8-comprehensions`] Handle trailing comma in fixes for `unnecessary-generator-list/set` (`C400`,`C401`) (#15929)

Commit
1 year ago
[`flake8-comprehensions`] Handle trailing comma in fixes for `unnecessary-generator-list/set` (`C400`,`C401`) (#15929) The unsafe fixes for the rules [unnecessary-generator-list (C400)](https://docs.astral.sh/ruff/rules/unnecessary-generator-list/#unnecessary-generator-list-c400) and [unnecessary-generator-set (C401)](https://docs.astral.sh/ruff/rules/unnecessary-generator-set/#unnecessary-generator-set-c401) used to introduce syntax errors if the argument to `list` or `set` had a trailing comma, because the fix would retain the comma after transforming the function call to a comprehension. This PR accounts for the trailing comma when replacing the end of the call with a `]` or `}`. Closes #15852
Author
Parents
Loading