diff --git a/mypy/build.py b/mypy/build.py index a24a27bf2dae..783a10aad532 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -275,9 +275,21 @@ def compute_search_paths(sources: List[BuildSource], if alt_lib_path: mypypath.insert(0, alt_lib_path) + package_path = tuple(_get_site_packages_dirs(options.python_executable)) + for site_dir in package_path: + assert site_dir not in lib_path + if site_dir in mypypath: + print("{} is in the MYPYPATH. Please remove it.".format(site_dir), file=sys.stderr) + sys.exit(1) + elif site_dir in python_path: + print("{} is in the PYTHONPATH. Please change directory" + " so it is not.".format(site_dir), + file=sys.stderr) + sys.exit(1) + return SearchPaths(tuple(reversed(python_path)), tuple(mypypath), - tuple(_get_site_packages_dirs(options.python_executable)), + package_path, tuple(lib_path))