File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030CWD = Path .cwd ()
3131TOOL_DIR = Path (__file__ ).parent
3232SITE_DIR = Path (sysconfig .get_paths ()["purelib" ])
33- ROOT_DIR = TOOL_DIR .parent
34-
3533
36- ROOT_SITE_DIR = (
37- ROOT_DIR / ".venv" / "Lib" / "site-packages"
38- if sys .platform == "win32"
39- else next ((ROOT_DIR / ".venv" / "lib" ).glob ("*/site-packages" ))
40- )
34+ ROOT_DIR = TOOL_DIR .parent
35+ if (ROOT_DIR / ".venv" ).is_dir ():
36+ __root_venv = ROOT_DIR / ".venv"
37+ __root_site = (
38+ __root_venv / "Lib" / "site-packages"
39+ if sys .platform == "win32"
40+ else next ((__root_venv / "lib" ).glob ("*/site-packages" ))
41+ )
42+ else :
43+ __root_site = None
44+ ROOT_SITE_DIR = __root_site
4145
4246ALLOWLISTS = [
4347 "common.txt" ,
@@ -130,9 +134,10 @@ def _rewrite_mypy_output(line: bytes, /) -> bytes:
130134 if package_lib in line :
131135 line = line .replace (package_lib , package_src )
132136
133- site_dir = str (SITE_DIR ).encode ()
134- if site_dir in line :
135- line = line .replace (site_dir , str (ROOT_SITE_DIR .relative_to (CWD )).encode ())
137+ if ROOT_SITE_DIR is not None :
138+ site_dir = str (SITE_DIR ).encode ()
139+ if site_dir in line :
140+ line = line .replace (site_dir , str (ROOT_SITE_DIR .relative_to (CWD )).encode ())
136141
137142 return line
138143
You can’t perform that action at this time.
0 commit comments