Total Complexity | 1 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import os |
||
|
|||
2 | |||
3 | from contextlib import contextmanager |
||
4 | from typing import Generator, Any |
||
5 | |||
6 | |||
7 | @contextmanager |
||
8 | def chdir(path) -> Generator[str, Any, None]: |
||
9 | """Change the cwd to the given path as a context manager.""" |
||
10 | current_path = os.getcwd() |
||
11 | os.chdir(path) |
||
12 | |||
13 | yield current_path |
||
14 | os.chdir(current_path) |
||
15 |