Tidy code by using contextlib.contextmanager annotation.