Skip to content

Commit bdaeea0

Browse files
committed
add typeshed, and tweak default_lib_path accordingly
1 parent b3bc75c commit bdaeea0

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "typeshed"]
2+
path = typeshed
3+
url = http://github.com/python/typeshed

mypy/build.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -199,28 +199,17 @@ def default_lib_path(data_dir: str, target: int, pyversion: Tuple[int, int],
199199
if path_env is not None:
200200
path[:0] = path_env.split(os.pathsep)
201201

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)
217210
if os.path.isdir(stubdir):
218211
path.append(stubdir)
219212

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-
224213
# Add fallback path that can be used if we have a broken installation.
225214
if sys.platform != 'win32':
226215
path.append('/usr/local/lib/mypy')

typeshed

Submodule typeshed added at 69e10b3

0 commit comments

Comments
 (0)