MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / update_env

Function update_env

tests/utils.py:165–178  ·  view source on GitHub ↗
(**new_env: str | Omit)

Source from the content-addressed store, hash-verified

163
164@contextlib.contextmanager
165def update_env(**new_env: str | Omit) -> Iterator[None]:
166 old = os.environ.copy()
167
168 try:
169 for name, value in new_env.items():
170 if isinstance(value, Omit):
171 os.environ.pop(name, None)
172 else:
173 os.environ[name] = value
174
175 yield None
176 finally:
177 os.environ.clear()
178 os.environ.update(old)
179
180
181_T = TypeVar("_T")

Calls 2

copyMethod · 0.45
updateMethod · 0.45