@contextmanager
def cwd(path: Union[(str, BasePathLike)]) -> Iterator[None]:
    'Context manager for temporary changing current working directory.'
    old_pwd = os.getcwd()
    os.chdir(path)
    try:
        (yield)
    finally:
        os.chdir(old_pwd)
Context manager for temporary changing current working directory.
@contextmanager
def cwd(path: Union[(str, BasePathLike)]) -> Iterator[None]:
    
    old_pwd = os.getcwd()
    os.chdir(path)
    try:
        (yield)
    finally:
        os.chdir(old_pwd)