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

Function update_env

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

Source from the content-addressed store, hash-verified

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

Calls 2

copyMethod · 0.45
updateMethod · 0.45