| 140 | |
| 141 | |
| 142 | class EnvironmentVariableGuard(Generic[T]): |
| 143 | variable: EnvironmentVariable[T] |
| 144 | original_value: T |
| 145 | |
| 146 | def __init__(self, variable: EnvironmentVariable[T], value: T): |
| 147 | self.variable = variable |
| 148 | self.original_value = variable.get() |
| 149 | self.variable.set(value) |
| 150 | |
| 151 | def __enter__(self) -> Self: |
| 152 | return self |
| 153 | |
| 154 | def __exit__(self, exc_type, exc_value, traceback) -> None: |
| 155 | self.variable.set(self.original_value) |
no outgoing calls