Passed
Push — main ( 834059...84c92a )
by Yohann
01:29
created

pincer.utils.directory.chdir()   A

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
import os
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
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