@contextmanager
def save_env():

    env_state = EnvStorage(store = True)

    try:
        yield
    finally:
        env_state.restore()
Saves and restores environment variables, example:
dataset/ETHPy150Open jlisee/xpkg/python/xpkg/util.py/save_env