Convert one-item dict.update() to bracket assignment

Proprietary

When .update() receives a dictionary literal containing exactly one key, rewrite it as a direct key assignment for clarity and efficiency. Only a call standing as a statement on a receiver whose type resolves to dict is rewritten, and only where the receiver, key and value are names, literals or attribute reads, since an assignment evaluates its value first. A call inside a with block whose context manager's name contains raises is left alone, since []= may raise a different exception.

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

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