(env: Dict[str, str])
Temporarily set environment variables inside the context manager and
    fully restore previous environment afterwards
Temporarily set environment variables inside the context manager and
    fully restore previous environment afterwards
Temporarily set environment variables inside the context manager and fully restore previous environment afterwards
def env_override(env: Dict[str, str]) -> Any:
    """Temporarily set environment variables inside the context manager and
    fully restore previous environment afterwards
    """
    original_env = {key: os.getenv(key) for key in env}
    os.environ.update(env)
    try:
        yield
    finally:
        for key, value in original_env.items():
            if value is None:
                del os.environ[key]
            else:
                os.environ[key] = value
def env_override ( env : Dict [ str , str ] ) -> Any : original_env = { key : os . getenv ( key ) for key in env } os . environ . update ( env ) try : yield finally : for key , value in original_env . items ( ) : if value is None : del os . environ [ key ] else : os . environ [ key ] = value