sourcery icon indicating copy to clipboard operation
sourcery copied to clipboard

Replace one item element slice for sequences like str with first slice index

Open Gobot1234 opened this issue 3 years ago • 1 comments

Checklist

  • [x] I think this refactoring is useful for everyone (if it's too specific, consider a custom rule)
  • [x] I have checked there are no similar issues suggesting the same thing

Description

For "hello world"[4:5] this can be safely replaced with "hello world"[4] and I think the intent is much clearer. There might be other sequences this can be applied to but I'm not currently aware of any.

Code Before

"hello world"[4:5]

Code After

"hello world"[4]

Gobot1234 avatar Oct 23 '22 12:10 Gobot1234

Thanks - I've added this to our backlog.

Hellebore avatar Oct 26 '22 09:10 Hellebore