Skip to content

Commit

Permalink
fix package root validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Nov 22, 2020
1 parent 804a574 commit b16a68c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit b16a68c

Please sign in to comment.