@@ -199,28 +199,17 @@ def default_lib_path(data_dir: str, target: int, pyversion: Tuple[int, int],
199
199
if path_env is not None :
200
200
path [:0 ] = path_env .split (os .pathsep )
201
201
202
- # Add library stubs directory. By convention, they are stored in the
203
- # stubs/x.y directory of the mypy installation.
204
- version_dir = '3.2'
205
- third_party_dir = 'third-party-3.2'
206
- if pyversion [0 ] < 3 :
207
- version_dir = '2.7'
208
- third_party_dir = 'third-party-2.7'
209
- path .append (os .path .join (data_dir , 'stubs' , version_dir ))
210
- path .append (os .path .join (data_dir , 'stubs' , third_party_dir ))
211
- path .append (os .path .join (data_dir , 'stubs-auto' , version_dir ))
212
- if sys .version_info .major == 3 :
213
- # Add additional stub directories.
214
- versions = ['3.3' , '3.4' , '3.5' , '3.6' ]
215
- for v in versions :
216
- stubdir = os .path .join (data_dir , 'stubs' , v )
202
+ auto = os .path .join (data_dir , 'stubs-auto' )
203
+ if os .path .isdir (auto ):
204
+ data_dir = auto
205
+
206
+ # E.g. for Python 3.5, try 2and3/, then 3/, then 3.5/
207
+ for v in ['2and3' , "%d" % pyversion [0 ], "%d.%d" % pyversion ]:
208
+ for lib_type in ['stdlib' , 'builtins' , 'third-party' ]:
209
+ stubdir = os .path .join (data_dir , 'typeshed' , lib_type , v )
217
210
if os .path .isdir (stubdir ):
218
211
path .append (stubdir )
219
212
220
- third_party_stubdir = os .path .join (data_dir , 'stubs' , 'third-party-' + v )
221
- if os .path .isdir (third_party_stubdir ):
222
- path .append (third_party_stubdir )
223
-
224
213
# Add fallback path that can be used if we have a broken installation.
225
214
if sys .platform != 'win32' :
226
215
path .append ('/usr/local/lib/mypy' )
0 commit comments