Use negative index instead of len() offset

Proprietary

Rewrite seq[len(seq) - 1] as seq[-1]. It only fires where seq is a side-effect-free name whose type resolves to a builtin sequence such as list or str, and where len is the builtin. Any offset other than 1 is left alone.

org.openrewrite.python.cleanup.SimplifyNegativeIndex
mod run . --recipe=org.openrewrite.python.cleanup.SimplifyNegativeIndex

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.