File tree 1 file changed +7
-2
lines changed 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,15 @@ def getsearchdirs():
33
33
# containing pyinfo.py
34
34
# - Otherwise, if mypy launched via console script, this is the directory of the script
35
35
# - Otherwise, if mypy launched via python -m mypy, this is the current directory
36
- # In all cases, this is safe to drop
36
+ # In all these cases, it is desirable to drop the first entry
37
37
# Note that mypy adds the cwd to SearchPaths.python_path, so we still find things on the
38
38
# cwd consistently (the return value here sets SearchPaths.package_path)
39
- abs_sys_path = (os .path .abspath (p ) for p in sys .path [1 :])
39
+
40
+ # Python 3.11 adds a "safe_path" flag wherein Python won't automatically prepend
41
+ # anything to sys.path. In this case, the first entry of sys.path is no longer special.
42
+ offset = 0 if sys .version_info >= (3 , 11 ) and sys .flags .safe_path else 1
43
+
44
+ abs_sys_path = (os .path .abspath (p ) for p in sys .path [offset :])
40
45
return [p for p in abs_sys_path if p not in excludes ]
41
46
42
47
You can’t perform that action at this time.
0 commit comments