Use negative index instead of len() offset
ProprietaryRewrite 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. SimplifyNegativeIndexmod run . --recipe= org. openrewrite. python. cleanup. SimplifyNegativeIndexInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.