From 8e205059705a97bd1b7b978b787c1878bbbb5309 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Tue, 30 Jun 2020 13:29:45 +0200 Subject: [PATCH] Resolve within working_dir context manager --- spacy/cli/project.py | 2 +- spacy/util.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/cli/project.py b/spacy/cli/project.py index 6ac604bdf..f0315dfe0 100644 --- a/spacy/cli/project.py +++ b/spacy/cli/project.py @@ -273,7 +273,7 @@ def project_init( silent (bool): Don't print any output (via DVC). analytics (bool): Opt-in to DVC analytics (defaults to False). """ - with working_dir(project_dir.resolve()) as cwd: + with working_dir(project_dir) as cwd: if git: run_command(["git", "init"]) init_cmd = ["dvc", "init"] diff --git a/spacy/util.py b/spacy/util.py index f8acebb63..1d998ec36 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -467,11 +467,12 @@ def working_dir(path: Union[str, Path]) -> None: directory, to prevent mismatches with relative paths. """ prev_cwd = Path.cwd() - os.chdir(str(path)) + current = Path(path).resolve() + os.chdir(str(current)) try: - yield Path(path).resolve() + yield current finally: - os.chdir(prev_cwd) + os.chdir(str(prev_cwd)) @contextmanager