(**new_env: str | Omit)
| 144 | |
| 145 | @contextlib.contextmanager |
| 146 | def update_env(**new_env: str | Omit) -> Iterator[None]: |
| 147 | old = os.environ.copy() |
| 148 | |
| 149 | try: |
| 150 | for name, value in new_env.items(): |
| 151 | if isinstance(value, Omit): |
| 152 | os.environ.pop(name, None) |
| 153 | else: |
| 154 | os.environ[name] = value |
| 155 | |
| 156 | yield None |
| 157 | finally: |
| 158 | os.environ.clear() |
| 159 | os.environ.update(old) |