From b16a68cf585ff2dd34661cd9b1e846166eb90edf Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sat, 21 Nov 2020 21:59:53 -0800 Subject: [PATCH] fix package root validation --- mypy/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index ddabfc0fbeb17..02d7dec148a54 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -974,7 +974,6 @@ def process_package_roots(fscache: Optional[FileSystemCache], assert fscache is not None # Since mypy doesn't know parser.error() raises. # Do some stuff with drive letters to make Windows happy (esp. tests). current_drive, _ = os.path.splitdrive(os.getcwd()) - dotdotslash = os.pardir + os.sep package_root = [] for root in options.package_root: if os.path.isabs(root): @@ -985,7 +984,7 @@ def process_package_roots(fscache: Optional[FileSystemCache], # Empty package root is always okay. if not root: root = os.curdir - if os.path.relpath(root).startswith(dotdotslash): + if os.path.relpath(root).split(os.sep)[0] == os.pardir: parser.error("Package root cannot be above current directory: %r" % root) root = os.path.normpath(os.path.abspath(root)) if not root.endswith(os.sep):