pyupgrade
pyupgrade copied to clipboard
Fold nested context managers.
Context managers can be grouped in the same way as imports.
with foo:
with bar:
body
becomes
with (foo, bar):
body
Resolves. https://github.com/asottile/pyupgrade/issues/872
PR updated as requested. In doing so I found a case I had fixed and then somehow missed during subsequent debugging.
I would appreciate insight into why the 3.9 code coverage is failing. It passes for 3.10.