<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def env(**kwargs: Union[Dict[str, str], None]) -> ContextManager: """Context handler to temporarily alter environment. If you supply a value of ``None``, then the associated key will be deleted from the environment. Args: kwargs: Environment variables to override Yields: Execution context with modified environment """

    old = os.environ.copy()
    try:
        os.environ.clear()
        # This apparent duplication is because ``putenv`` doesn’t update
        # ``os.environ``, and ``os.environ`` changes aren’t propagated to
        # subprocesses.
        for key, value in old.items():
            os.environ[key] = value  # NOQA: B003
            os.putenv(key, value)
        for key, value in kwargs.items():
            if value is None:
                del os.environ[key]
            else:
                os.environ[key] = value  # NOQA: B003
                os.putenv(key, value)
        yield
    finally:
        os.environ.clear()
        for key, value in old.items():
            os.environ[key] = value  # NOQA: B003
            os.putenv(key, value)