[flake8-simplify] Fix SIM905 autofix for rsplit creating a reversed list literal#18045
[flake8-simplify] Fix SIM905 autofix for rsplit creating a reversed list literal#18045dylwil3 merged 2 commits intoastral-sh:mainfrom
flake8-simplify] Fix SIM905 autofix for rsplit creating a reversed list literal#18045Conversation
…rsed list literal
|
.../flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap
Outdated
Show resolved
Hide resolved
dylwil3
left a comment
There was a problem hiding this comment.
Thanks for working on this! I wonder if the fix isn't quite right, and whether the change could be simpler.
| Direction::Right => value.rsplitn(split_n + 1, sep_value).collect(), | ||
| } | ||
| value.splitn(split_n + 1, sep_value).collect() | ||
| } else { | ||
| match direction { | ||
| Direction::Left => value.split(sep_value).collect(), | ||
| Direction::Right => value.rsplit(sep_value).collect(), |
There was a problem hiding this comment.
Does it not work to just do .reverse after rsplit and rsplitn?
There was a problem hiding this comment.
I tried using .rev but the compiler gave me an error, something about a trait not being implemented for the return type of these functions you mentioned.
There was a problem hiding this comment.
Since this isn't a super performance-sensitive spot in the code, you could try collecting first?
There was a problem hiding this comment.
(Actually - we collect anyway and reversing a Vec doesn't re-allocate, so I think it's not even a perf hit really)
…eepish * origin/main: [ty] Induct into instances and subclasses when finding and applying generics (#18052) [ty] Allow classes to inherit from `type[Any]` or `type[Unknown]` (#18060) [ty] Allow a class to inherit from an intersection if the intersection contains a dynamic type and the intersection is not disjoint from `type` (#18055) [ty] Narrowing for `hasattr()` (#18053) Update reference documentation for `--python-version` (#18056) [`flake8-bugbear`] Ignore `B028` if `skip_file_prefixes` is present (#18047) [`airflow`] Apply try-catch guard to all AIR3 rules (`AIR3`) (#17887) [`pylint`] add fix safety section (`PLW3301`) (#17878) Update `--python` to accept paths to executables in virtual environments (#17954) [`pylint`] add fix safety section (`PLE4703`) (#17824) [`ruff`] Implement a recursive check for `RUF060` (#17976) [`flake8-use-pathlib`] `PTH*` suppress diagnostic for all `os.*` functions that have the `dir_fd` parameter (#17968) [`refurb`] Mark autofix as safe only for number literals in `FURB116` (#17692) [`flake8-simplify`] Fix `SIM905` autofix for `rsplit` creating a reversed list literal (#18045) Avoid initializing progress bars early (#18049)
…eep-dish * origin/main: [ty] Infer parameter specializations of generic aliases (#18021) [ty] Understand homogeneous tuple annotations (#17998) [ty] Induct into instances and subclasses when finding and applying generics (#18052) [ty] Allow classes to inherit from `type[Any]` or `type[Unknown]` (#18060) [ty] Allow a class to inherit from an intersection if the intersection contains a dynamic type and the intersection is not disjoint from `type` (#18055) [ty] Narrowing for `hasattr()` (#18053) Update reference documentation for `--python-version` (#18056) [`flake8-bugbear`] Ignore `B028` if `skip_file_prefixes` is present (#18047) [`airflow`] Apply try-catch guard to all AIR3 rules (`AIR3`) (#17887) [`pylint`] add fix safety section (`PLW3301`) (#17878) Update `--python` to accept paths to executables in virtual environments (#17954) [`pylint`] add fix safety section (`PLE4703`) (#17824) [`ruff`] Implement a recursive check for `RUF060` (#17976) [`flake8-use-pathlib`] `PTH*` suppress diagnostic for all `os.*` functions that have the `dir_fd` parameter (#17968) [`refurb`] Mark autofix as safe only for number literals in `FURB116` (#17692) [`flake8-simplify`] Fix `SIM905` autofix for `rsplit` creating a reversed list literal (#18045) Avoid initializing progress bars early (#18049)
…rsed list literal (astral-sh#18045) ## Summary Fixes astral-sh#18042
Summary
Fixes #18042
Test Plan
Update existing snapshot tests.