X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/eb5d175c9cd3c14a0731f8afd0cc5a18264353e7..6ae8457a8628345c59fed22c58728ffa258a3e76:/docs/the_black_code_style/future_style.md?ds=sidebyside diff --git a/docs/the_black_code_style/future_style.md b/docs/the_black_code_style/future_style.md index fab4bca..a17d9a1 100644 --- a/docs/the_black_code_style/future_style.md +++ b/docs/the_black_code_style/future_style.md @@ -34,6 +34,19 @@ with \ Although when the target version is Python 3.9 or higher, _Black_ will use parentheses instead since they're allowed in Python 3.9 and higher. +An alternative to consider if the backslashes in the above formatting are undesirable is +to use {external:py:obj}`contextlib.ExitStack` to combine context managers in the +following way: + +```python +with contextlib.ExitStack() as exit_stack: + cm1 = exit_stack.enter_context(make_context_manager(1)) + cm2 = exit_stack.enter_context(make_context_manager(2)) + cm3 = exit_stack.enter_context(make_context_manager(3)) + cm4 = exit_stack.enter_context(make_context_manager(4)) + ... +``` + ## Preview style Experimental, potentially disruptive style changes are gathered under the `--preview`