@@ -668,10 +668,13 @@ def mypy_path() -> list[str]:
668668def default_lib_path (
669669 data_dir : str , pyversion : tuple [int , int ], custom_typeshed_dir : str | None
670670) -> list [str ]:
671- """Return default standard library search paths."""
671+ """Return default standard library search paths. Guaranteed to be normalised."""
672+
673+ data_dir = os .path .abspath (data_dir )
672674 path : list [str ] = []
673675
674676 if custom_typeshed_dir :
677+ custom_typeshed_dir = os .path .abspath (custom_typeshed_dir )
675678 typeshed_dir = os .path .join (custom_typeshed_dir , "stdlib" )
676679 mypy_extensions_dir = os .path .join (custom_typeshed_dir , "stubs" , "mypy-extensions" )
677680 versions_file = os .path .join (typeshed_dir , "VERSIONS" )
@@ -711,7 +714,7 @@ def default_lib_path(
711714
712715@functools .lru_cache (maxsize = None )
713716def get_search_dirs (python_executable : str | None ) -> tuple [list [str ], list [str ]]:
714- """Find package directories for given python.
717+ """Find package directories for given python. Guaranteed to return absolute paths.
715718
716719 This runs a subprocess call, which generates a list of the directories in sys.path.
717720 To avoid repeatedly calling a subprocess (which can be slow!) we
@@ -773,6 +776,7 @@ def compute_search_paths(
773776 root_dir = os .getenv ("MYPY_TEST_PREFIX" , None )
774777 if not root_dir :
775778 root_dir = os .path .dirname (os .path .dirname (__file__ ))
779+ root_dir = os .path .abspath (root_dir )
776780 lib_path .appendleft (os .path .join (root_dir , "test-data" , "unit" , "lib-stub" ))
777781 # alt_lib_path is used by some tests to bypass the normal lib_path mechanics.
778782 # If we don't have one, grab directories of source files.
@@ -829,6 +833,7 @@ def compute_search_paths(
829833 return SearchPaths (
830834 python_path = tuple (reversed (python_path )),
831835 mypy_path = tuple (mypypath ),
836+ # package_path and typeshed_path must be normalised and absolute via os.path.abspath
832837 package_path = tuple (sys_path + site_packages ),
833838 typeshed_path = tuple (lib_path ),
834839 )
0 commit comments