diff --git a/.gitignore b/.gitignore index a3dc56492402..f8cc81bf3bf9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,19 @@ -build/ -__pycache__ +# Backup and compiled files +__pycache__/ *.pyc *~ + +# Unclassified @* -/build /env docs/build/ *.iml /out/ + +# Used by setup.py and tox +/build/ +/dist/ +/elsewhere/ +/.tox/ +/MANIFEST +/lib-typing/3.2/mypy_lang.egg-info/ diff --git a/.travis.yml b/.travis.yml index 0b60e361e889..4c5e305886db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,27 @@ sudo: false language: python -python: - - "3.2" - - "3.3" - - "3.4" - - "3.5" - # Pypy build is disaabled because it doubles the travis build time, and it rarely fails - # unless one one of the other builds fails. - # - "pypy3" install: - - pip install -r test-requirements.txt - - python setup.py install + - pip install tox script: - - python runtests.py -v + - tox notifications: irc: channels: - "chat.freenode.net##mypy" use_notice: true + +matrix: + include: + - python: "3.2" + env: TOXENV=py32 + - python: "3.3" + env: TOXENV=py33 + - python: "3.4" + env: TOXENV=py34 + - python: "3.5" + env: TOXENV=py35 + - python: "pypy3" + env: TOXENV=pypy3 diff --git a/lib-python/3.2/base64.py b/lib-python/3.2/base64.pyi similarity index 100% rename from lib-python/3.2/base64.py rename to lib-python/3.2/base64.pyi diff --git a/lib-python/3.2/fnmatch.py b/lib-python/3.2/fnmatch.pyi similarity index 100% rename from lib-python/3.2/fnmatch.py rename to lib-python/3.2/fnmatch.pyi diff --git a/lib-python/3.2/genericpath.py b/lib-python/3.2/genericpath.pyi similarity index 100% rename from lib-python/3.2/genericpath.py rename to lib-python/3.2/genericpath.pyi diff --git a/lib-python/3.2/getopt.py b/lib-python/3.2/getopt.pyi similarity index 100% rename from lib-python/3.2/getopt.py rename to lib-python/3.2/getopt.pyi diff --git a/lib-python/3.2/glob.py b/lib-python/3.2/glob.pyi similarity index 100% rename from lib-python/3.2/glob.py rename to lib-python/3.2/glob.pyi diff --git a/lib-python/3.2/incomplete/logging/__init__.py b/lib-python/3.2/incomplete/logging/__init__.pyi similarity index 100% rename from lib-python/3.2/incomplete/logging/__init__.py rename to lib-python/3.2/incomplete/logging/__init__.pyi diff --git a/stubs/2.7/email/__init__.pyi b/lib-python/3.2/incomplete/urllib/__init__.pyi similarity index 100% rename from stubs/2.7/email/__init__.pyi rename to lib-python/3.2/incomplete/urllib/__init__.pyi diff --git a/lib-python/3.2/incomplete/urllib/parse.py b/lib-python/3.2/incomplete/urllib/parse.pyi similarity index 100% rename from lib-python/3.2/incomplete/urllib/parse.py rename to lib-python/3.2/incomplete/urllib/parse.pyi diff --git a/lib-python/3.2/posixpath.py b/lib-python/3.2/posixpath.pyi similarity index 100% rename from lib-python/3.2/posixpath.py rename to lib-python/3.2/posixpath.pyi diff --git a/lib-python/3.2/pprint.py b/lib-python/3.2/pprint.pyi similarity index 100% rename from lib-python/3.2/pprint.py rename to lib-python/3.2/pprint.pyi diff --git a/lib-python/3.2/random.py b/lib-python/3.2/random.pyi similarity index 100% rename from lib-python/3.2/random.py rename to lib-python/3.2/random.pyi diff --git a/lib-python/3.2/shutil.py b/lib-python/3.2/shutil.pyi similarity index 100% rename from lib-python/3.2/shutil.py rename to lib-python/3.2/shutil.pyi diff --git a/lib-python/3.2/subprocess.py b/lib-python/3.2/subprocess.pyi similarity index 100% rename from lib-python/3.2/subprocess.py rename to lib-python/3.2/subprocess.pyi diff --git a/lib-python/3.2/tempfile.py b/lib-python/3.2/tempfile.pyi similarity index 100% rename from lib-python/3.2/tempfile.py rename to lib-python/3.2/tempfile.pyi diff --git a/stubs/2.7/email/mime/__init__.pyi b/lib-python/3.2/test/__init__.pyi similarity index 100% rename from stubs/2.7/email/mime/__init__.pyi rename to lib-python/3.2/test/__init__.pyi diff --git a/lib-python/3.2/test/subprocessdata/fd_status.py b/lib-python/3.2/test/subprocessdata/fd_status.pyi similarity index 100% rename from lib-python/3.2/test/subprocessdata/fd_status.py rename to lib-python/3.2/test/subprocessdata/fd_status.pyi diff --git a/lib-python/3.2/test/subprocessdata/input_reader.py b/lib-python/3.2/test/subprocessdata/input_reader.pyi similarity index 100% rename from lib-python/3.2/test/subprocessdata/input_reader.py rename to lib-python/3.2/test/subprocessdata/input_reader.pyi diff --git a/lib-python/3.2/test/subprocessdata/qcat.py b/lib-python/3.2/test/subprocessdata/qcat.pyi similarity index 100% rename from lib-python/3.2/test/subprocessdata/qcat.py rename to lib-python/3.2/test/subprocessdata/qcat.pyi diff --git a/lib-python/3.2/test/subprocessdata/qgrep.py b/lib-python/3.2/test/subprocessdata/qgrep.pyi similarity index 100% rename from lib-python/3.2/test/subprocessdata/qgrep.py rename to lib-python/3.2/test/subprocessdata/qgrep.pyi diff --git a/lib-python/3.2/test/subprocessdata/sigchild_ignore.py b/lib-python/3.2/test/subprocessdata/sigchild_ignore.pyi similarity index 100% rename from lib-python/3.2/test/subprocessdata/sigchild_ignore.py rename to lib-python/3.2/test/subprocessdata/sigchild_ignore.pyi diff --git a/lib-python/3.2/test/support.py b/lib-python/3.2/test/support.pyi similarity index 100% rename from lib-python/3.2/test/support.py rename to lib-python/3.2/test/support.pyi diff --git a/lib-python/3.2/test/test_base64.py b/lib-python/3.2/test/test_base64.pyi similarity index 100% rename from lib-python/3.2/test/test_base64.py rename to lib-python/3.2/test/test_base64.pyi diff --git a/lib-python/3.2/test/test_fnmatch.py b/lib-python/3.2/test/test_fnmatch.pyi similarity index 100% rename from lib-python/3.2/test/test_fnmatch.py rename to lib-python/3.2/test/test_fnmatch.pyi diff --git a/lib-python/3.2/test/test_genericpath.py b/lib-python/3.2/test/test_genericpath.pyi similarity index 100% rename from lib-python/3.2/test/test_genericpath.py rename to lib-python/3.2/test/test_genericpath.pyi diff --git a/lib-python/3.2/test/test_getopt.py b/lib-python/3.2/test/test_getopt.pyi similarity index 100% rename from lib-python/3.2/test/test_getopt.py rename to lib-python/3.2/test/test_getopt.pyi diff --git a/lib-python/3.2/test/test_glob.py b/lib-python/3.2/test/test_glob.pyi similarity index 100% rename from lib-python/3.2/test/test_glob.py rename to lib-python/3.2/test/test_glob.pyi diff --git a/lib-python/3.2/test/test_posixpath.py b/lib-python/3.2/test/test_posixpath.pyi similarity index 100% rename from lib-python/3.2/test/test_posixpath.py rename to lib-python/3.2/test/test_posixpath.pyi diff --git a/lib-python/3.2/test/test_pprint.py b/lib-python/3.2/test/test_pprint.pyi similarity index 100% rename from lib-python/3.2/test/test_pprint.py rename to lib-python/3.2/test/test_pprint.pyi diff --git a/lib-python/3.2/test/test_random.py b/lib-python/3.2/test/test_random.pyi similarity index 100% rename from lib-python/3.2/test/test_random.py rename to lib-python/3.2/test/test_random.pyi diff --git a/lib-python/3.2/test/test_set.py b/lib-python/3.2/test/test_set.pyi similarity index 100% rename from lib-python/3.2/test/test_set.py rename to lib-python/3.2/test/test_set.pyi diff --git a/lib-python/3.2/test/test_shutil.py b/lib-python/3.2/test/test_shutil.pyi similarity index 100% rename from lib-python/3.2/test/test_shutil.py rename to lib-python/3.2/test/test_shutil.pyi diff --git a/lib-python/3.2/test/test_subprocess.py b/lib-python/3.2/test/test_subprocess.pyi similarity index 100% rename from lib-python/3.2/test/test_subprocess.py rename to lib-python/3.2/test/test_subprocess.pyi diff --git a/lib-python/3.2/test/test_tempfile.py b/lib-python/3.2/test/test_tempfile.pyi similarity index 100% rename from lib-python/3.2/test/test_tempfile.py rename to lib-python/3.2/test/test_tempfile.pyi diff --git a/lib-python/3.2/test/test_textwrap.py b/lib-python/3.2/test/test_textwrap.pyi similarity index 100% rename from lib-python/3.2/test/test_textwrap.py rename to lib-python/3.2/test/test_textwrap.pyi diff --git a/lib-python/3.2/test/tf_inherit_check.py b/lib-python/3.2/test/tf_inherit_check.pyi similarity index 100% rename from lib-python/3.2/test/tf_inherit_check.py rename to lib-python/3.2/test/tf_inherit_check.pyi diff --git a/lib-python/3.2/textwrap.py b/lib-python/3.2/textwrap.pyi similarity index 100% rename from lib-python/3.2/textwrap.py rename to lib-python/3.2/textwrap.pyi diff --git a/mypy/build.py b/mypy/build.py index e611da81235e..da71903e1fe3 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -27,7 +27,7 @@ from mypy import parse from mypy import stats from mypy.report import Reports -from mypy import defaults +from mypy.syntax.dialect import Dialect, Implementation, default_implementation # We need to know the location of this file to load data, but @@ -95,8 +95,7 @@ def build(program_path: str, argument: str = None, program_text: Union[str, bytes] = None, alt_lib_path: str = None, - bin_dir: str = None, - pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION, + implementation: Implementation = None, custom_typing_module: str = None, report_dirs: Dict[str, str] = {}, flags: List[str] = None, @@ -116,19 +115,18 @@ def build(program_path: str, program_text: the main source file contents; if omitted, read from file alt_lib_dir: an additional directory for looking up library modules (takes precedence over other directories) - bin_dir: directory containing the mypy script, used for finding data - directories; if omitted, use '.' as the data directory - pyversion: Python version (major, minor) + implementation: Python version custom_typing_module: if not None, use this module id as an alias for typing flags: list of build options (e.g. COMPILE_ONLY) """ flags = flags or [] module = module or '__main__' + implementation = implementation or default_implementation() - data_dir = default_data_dir(bin_dir) + data_dir = default_data_dir() # Determine the default module search path. - lib_path = default_lib_path(data_dir, target, pyversion, python_path) + lib_path = default_lib_path(data_dir, target, implementation, python_path) if TEST_BUILTINS in flags: # Use stub builtins (to speed up test cases and to make them easier to @@ -160,7 +158,7 @@ def build(program_path: str, # # Ignore current directory prefix in error messages. manager = BuildManager(data_dir, lib_path, target, - pyversion=pyversion, flags=flags, + dialect=implementation.base_dialect, flags=flags, ignore_prefix=os.getcwd(), custom_typing_module=custom_typing_module, reports=reports) @@ -176,32 +174,15 @@ def build(program_path: str, return result -def default_data_dir(bin_dir: str) -> str: - # TODO fix this logic - if not bin_dir: - # Default to directory containing this file's parent. - return os.path.dirname(os.path.dirname(__file__)) - base = os.path.basename(bin_dir) - dir = os.path.dirname(bin_dir) - if (sys.platform == 'win32' and base.lower() == 'mypy' - and not os.path.isdir(os.path.join(dir, 'stubs'))): - # Installed, on Windows. - return os.path.join(dir, 'Lib', 'mypy') - elif base == 'mypy': - # Assume that we have a repo check out or unpacked source tarball. - return os.path.dirname(bin_dir) - elif base == 'bin': - # Installed to somewhere (can be under /usr/local or anywhere). - return os.path.join(dir, 'lib', 'mypy') - elif base == 'python3': - # Assume we installed python3 with brew on os x - return os.path.join(os.path.dirname(dir), 'lib', 'mypy') - else: - # Don't know where to find the data files! - raise RuntimeError("Broken installation: can't determine base dir") +def is_installed() -> bool: + return 'site-packages' in __file__ or 'dist-packages' in __file__ + + +def default_data_dir() -> str: + return os.path.join(os.path.dirname(__file__), 'data') -def default_lib_path(data_dir: str, target: int, pyversion: Tuple[int, int], +def default_lib_path(data_dir: str, target: int, implementation: Implementation, python_path: bool) -> List[str]: """Return default standard library search paths.""" # IDEA: Make this more portable. @@ -216,14 +197,12 @@ def default_lib_path(data_dir: str, target: int, pyversion: Tuple[int, int], # stubs/x.y directory of the mypy installation. Additionally, stubs # for earlier versions in the same major version will be added, and # as a last resort, third-party stubs will be added. - if pyversion == 2: - major, minor = 2, 7 + major = implementation.base_dialect.major + minor = implementation.base_dialect.minor + if major == 3: + version_dir = '3.2' + third_party_dir = 'third-party-3.2' else: - # See bug #886 - major, minor = sys.version_info[0], sys.version_info[1] - version_dir = '3.2' - third_party_dir = 'third-party-3.2' - if pyversion[0] < 3: version_dir = '2.7' third_party_dir = 'third-party-2.7' path.append(os.path.join(data_dir, 'stubs', version_dir)) @@ -244,13 +223,9 @@ def default_lib_path(data_dir: str, target: int, pyversion: Tuple[int, int], if os.path.isdir(third_party_stubdir): path.append(third_party_stubdir) - # Add fallback path that can be used if we have a broken installation. - if sys.platform != 'win32': - path.append('/usr/local/lib/mypy') - # Contents of Python's sys.path go last, to prefer the stubs if python_path: - path.extend(sys.path) + path.extend(implementation.python_path) return path @@ -292,7 +267,7 @@ class BuildManager: Semantic analyzer, pass 3 type_checker: Type checker errors: Used for reporting all errors - pyversion: Python version (major, minor) + dialect: Python version flags: Build options states: States of all individual files that are being processed. Each file in a build is always represented @@ -310,7 +285,7 @@ class BuildManager: def __init__(self, data_dir: str, lib_path: List[str], target: int, - pyversion: Tuple[int, int], + dialect: Dialect, flags: List[str], ignore_prefix: str, custom_typing_module: str, @@ -320,16 +295,16 @@ def __init__(self, data_dir: str, self.errors.set_ignore_prefix(ignore_prefix) self.lib_path = lib_path self.target = target - self.pyversion = pyversion + self.dialect = dialect self.flags = flags self.custom_typing_module = custom_typing_module self.reports = reports self.semantic_analyzer = SemanticAnalyzer(lib_path, self.errors, - pyversion=pyversion) + dialect=dialect) self.semantic_analyzer_pass3 = ThirdPass(self.errors) self.type_checker = TypeChecker(self.errors, self.semantic_analyzer.modules, - self.pyversion) + dialect) self.states = [] # type: List[State] self.module_files = {} # type: Dict[str, str] self.module_deps = {} # type: Dict[Tuple[str, str], bool] @@ -740,7 +715,7 @@ def parse(self, source_text: Union[str, bytes], fnam: str) -> MypyFile: """ num_errs = self.errors().num_messages() tree = parse.parse(source_text, fnam, self.errors(), - pyversion=self.manager.pyversion, + dialect=self.manager.dialect, custom_typing_module=self.manager.custom_typing_module) tree._fullname = self.id if self.errors().num_messages() != num_errs: diff --git a/mypy/checker.py b/mypy/checker.py index f91d34f69054..a0cf3cd212ed 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -33,7 +33,7 @@ from mypy.sametypes import is_same_type from mypy.messages import MessageBuilder import mypy.checkexpr -from mypy import defaults +from mypy.syntax.dialect import Dialect, default_dialect from mypy import messages from mypy.subtypes import ( is_subtype, is_equivalent, is_proper_subtype, @@ -302,7 +302,7 @@ class TypeChecker(NodeVisitor[Type]): """ # Target Python version - pyversion = defaults.PYTHON3_VERSION + dialect = None # type: Dialect # Are we type checking a stub? is_stub = False # Error message reporter @@ -337,7 +337,7 @@ class TypeChecker(NodeVisitor[Type]): modules = None # type: Dict[str, MypyFile] def __init__(self, errors: Errors, modules: Dict[str, MypyFile], - pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION) -> None: + dialect: Dialect = default_dialect()) -> None: """Construct a type checker. Use errors to report type check errors. Assume symtable has been @@ -346,7 +346,7 @@ def __init__(self, errors: Errors, modules: Dict[str, MypyFile], self.expr_checker self.errors = errors self.modules = modules - self.pyversion = pyversion + self.dialect = dialect self.msg = MessageBuilder(errors) self.type_map = {} self.binder = ConditionalTypeBinder() @@ -1548,7 +1548,7 @@ def type_check_raise(self, e: Node, s: RaiseStmt) -> None: # Good! return None # Else fall back to the checks below (which will fail). - if isinstance(typ, TupleType) and self.pyversion[0] == 2: + if isinstance(typ, TupleType) and self.dialect.major == 2: # allow `raise type, value, traceback` # https://docs.python.org/2/reference/simple_stmts.html#the-raise-statement # TODO: Also check tuple item types. @@ -1660,7 +1660,7 @@ def analyze_iterable_item_type(self, expr: Node) -> Type: method = echk.analyze_external_member_access('__iter__', iterable, expr) iterator = echk.check_call(method, [], [], expr)[0] - if self.pyversion[0] >= 3: + if self.dialect.major >= 3: nextmethod = '__next__' else: nextmethod = 'next' diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index a7c84b0cb056..1c411d4bf2ac 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -727,7 +727,7 @@ def visit_complex_expr(self, e: ComplexExpr) -> Type: def visit_ellipsis(self, e: EllipsisExpr) -> Type: """Type check '...'.""" - if self.chk.pyversion[0] >= 3: + if self.chk.dialect.major >= 3: return self.named_type('builtins.ellipsis') else: # '...' is not valid in normal Python 2 code, but it can @@ -821,7 +821,7 @@ def visit_comparison_expr(self, e: ComparisonExpr) -> Type: return result def get_operator_method(self, op: str) -> str: - if op == '/' and self.chk.pyversion[0] == 2: + if op == '/' and self.chk.dialect.major == 2: # TODO also check for "from __future__ import division" return '__div__' else: @@ -893,7 +893,7 @@ def check_op(self, method: str, base_type: Type, arg: Node, self.msg) def get_reverse_op_method(self, method: str) -> str: - if method == '__div__' and self.chk.pyversion[0] == 2: + if method == '__div__' and self.chk.dialect.major == 2: return '__rdiv__' else: return nodes.reverse_op_methods[method] diff --git a/mypy/constraints.py b/mypy/constraints.py index e8794338c20d..ba9136a33b22 100644 --- a/mypy/constraints.py +++ b/mypy/constraints.py @@ -273,6 +273,12 @@ def infer_against_any(self, types: List[Type]) -> List[Constraint]: res.extend(infer_constraints(t, AnyType(), self.direction)) return res + def visit_overloaded(self, type: Overloaded) -> List[Constraint]: + res = [] # type: List[Constraint] + for t in type.items(): + res.extend(infer_constraints(t, self.actual, self.direction)) + return res + def negate_constraints(constraints: List[Constraint]) -> List[Constraint]: res = [] # type: List[Constraint] diff --git a/stubs/2.7/Queue.pyi b/mypy/data/stubs/2.7/Queue.pyi similarity index 100% rename from stubs/2.7/Queue.pyi rename to mypy/data/stubs/2.7/Queue.pyi diff --git a/stubs/2.7/StringIO.pyi b/mypy/data/stubs/2.7/StringIO.pyi similarity index 100% rename from stubs/2.7/StringIO.pyi rename to mypy/data/stubs/2.7/StringIO.pyi diff --git a/stubs/2.7/UserDict.pyi b/mypy/data/stubs/2.7/UserDict.pyi similarity index 100% rename from stubs/2.7/UserDict.pyi rename to mypy/data/stubs/2.7/UserDict.pyi diff --git a/stubs/2.7/__future__.pyi b/mypy/data/stubs/2.7/__future__.pyi similarity index 100% rename from stubs/2.7/__future__.pyi rename to mypy/data/stubs/2.7/__future__.pyi diff --git a/stubs/2.7/_random.pyi b/mypy/data/stubs/2.7/_random.pyi similarity index 100% rename from stubs/2.7/_random.pyi rename to mypy/data/stubs/2.7/_random.pyi diff --git a/stubs/2.7/abc.pyi b/mypy/data/stubs/2.7/abc.pyi similarity index 100% rename from stubs/2.7/abc.pyi rename to mypy/data/stubs/2.7/abc.pyi diff --git a/stubs/2.7/argparse.pyi b/mypy/data/stubs/2.7/argparse.pyi similarity index 100% rename from stubs/2.7/argparse.pyi rename to mypy/data/stubs/2.7/argparse.pyi diff --git a/stubs/2.7/atexit.pyi b/mypy/data/stubs/2.7/atexit.pyi similarity index 100% rename from stubs/2.7/atexit.pyi rename to mypy/data/stubs/2.7/atexit.pyi diff --git a/stubs/2.7/base64.pyi b/mypy/data/stubs/2.7/base64.pyi similarity index 100% rename from stubs/2.7/base64.pyi rename to mypy/data/stubs/2.7/base64.pyi diff --git a/stubs/2.7/binascii.pyi b/mypy/data/stubs/2.7/binascii.pyi similarity index 100% rename from stubs/2.7/binascii.pyi rename to mypy/data/stubs/2.7/binascii.pyi diff --git a/stubs/2.7/builtins.pyi b/mypy/data/stubs/2.7/builtins.pyi similarity index 100% rename from stubs/2.7/builtins.pyi rename to mypy/data/stubs/2.7/builtins.pyi diff --git a/stubs/2.7/cStringIO.pyi b/mypy/data/stubs/2.7/cStringIO.pyi similarity index 100% rename from stubs/2.7/cStringIO.pyi rename to mypy/data/stubs/2.7/cStringIO.pyi diff --git a/stubs/2.7/codecs.pyi b/mypy/data/stubs/2.7/codecs.pyi similarity index 100% rename from stubs/2.7/codecs.pyi rename to mypy/data/stubs/2.7/codecs.pyi diff --git a/stubs/2.7/collections.pyi b/mypy/data/stubs/2.7/collections.pyi similarity index 100% rename from stubs/2.7/collections.pyi rename to mypy/data/stubs/2.7/collections.pyi diff --git a/stubs/2.7/compileall.pyi b/mypy/data/stubs/2.7/compileall.pyi similarity index 100% rename from stubs/2.7/compileall.pyi rename to mypy/data/stubs/2.7/compileall.pyi diff --git a/stubs/2.7/contextlib.pyi b/mypy/data/stubs/2.7/contextlib.pyi similarity index 100% rename from stubs/2.7/contextlib.pyi rename to mypy/data/stubs/2.7/contextlib.pyi diff --git a/stubs/2.7/copy.pyi b/mypy/data/stubs/2.7/copy.pyi similarity index 100% rename from stubs/2.7/copy.pyi rename to mypy/data/stubs/2.7/copy.pyi diff --git a/stubs/2.7/csv.pyi b/mypy/data/stubs/2.7/csv.pyi similarity index 100% rename from stubs/2.7/csv.pyi rename to mypy/data/stubs/2.7/csv.pyi diff --git a/stubs/2.7/datetime.pyi b/mypy/data/stubs/2.7/datetime.pyi similarity index 100% rename from stubs/2.7/datetime.pyi rename to mypy/data/stubs/2.7/datetime.pyi diff --git a/stubs/2.7/difflib.pyi b/mypy/data/stubs/2.7/difflib.pyi similarity index 100% rename from stubs/2.7/difflib.pyi rename to mypy/data/stubs/2.7/difflib.pyi diff --git a/stubs/2.7/distutils/__init__.pyi b/mypy/data/stubs/2.7/distutils/__init__.pyi similarity index 100% rename from stubs/2.7/distutils/__init__.pyi rename to mypy/data/stubs/2.7/distutils/__init__.pyi diff --git a/stubs/2.7/distutils/version.pyi b/mypy/data/stubs/2.7/distutils/version.pyi similarity index 100% rename from stubs/2.7/distutils/version.pyi rename to mypy/data/stubs/2.7/distutils/version.pyi diff --git a/stubs/2.7/email/MIMEText.pyi b/mypy/data/stubs/2.7/email/MIMEText.pyi similarity index 100% rename from stubs/2.7/email/MIMEText.pyi rename to mypy/data/stubs/2.7/email/MIMEText.pyi diff --git a/stubs/2.7/xml/__init__.pyi b/mypy/data/stubs/2.7/email/__init__.pyi similarity index 100% rename from stubs/2.7/xml/__init__.pyi rename to mypy/data/stubs/2.7/email/__init__.pyi diff --git a/stubs/2.7/xml/sax/__init__.pyi b/mypy/data/stubs/2.7/email/mime/__init__.pyi similarity index 100% rename from stubs/2.7/xml/sax/__init__.pyi rename to mypy/data/stubs/2.7/email/mime/__init__.pyi diff --git a/stubs/2.7/email/mime/base.pyi b/mypy/data/stubs/2.7/email/mime/base.pyi similarity index 100% rename from stubs/2.7/email/mime/base.pyi rename to mypy/data/stubs/2.7/email/mime/base.pyi diff --git a/stubs/2.7/email/mime/multipart.pyi b/mypy/data/stubs/2.7/email/mime/multipart.pyi similarity index 100% rename from stubs/2.7/email/mime/multipart.pyi rename to mypy/data/stubs/2.7/email/mime/multipart.pyi diff --git a/stubs/2.7/email/mime/nonmultipart.pyi b/mypy/data/stubs/2.7/email/mime/nonmultipart.pyi similarity index 100% rename from stubs/2.7/email/mime/nonmultipart.pyi rename to mypy/data/stubs/2.7/email/mime/nonmultipart.pyi diff --git a/stubs/2.7/email/mime/text.pyi b/mypy/data/stubs/2.7/email/mime/text.pyi similarity index 100% rename from stubs/2.7/email/mime/text.pyi rename to mypy/data/stubs/2.7/email/mime/text.pyi diff --git a/stubs/2.7/errno.pyi b/mypy/data/stubs/2.7/errno.pyi similarity index 100% rename from stubs/2.7/errno.pyi rename to mypy/data/stubs/2.7/errno.pyi diff --git a/stubs/2.7/fcntl.pyi b/mypy/data/stubs/2.7/fcntl.pyi similarity index 100% rename from stubs/2.7/fcntl.pyi rename to mypy/data/stubs/2.7/fcntl.pyi diff --git a/stubs/2.7/fnmatch.pyi b/mypy/data/stubs/2.7/fnmatch.pyi similarity index 100% rename from stubs/2.7/fnmatch.pyi rename to mypy/data/stubs/2.7/fnmatch.pyi diff --git a/stubs/2.7/functools.pyi b/mypy/data/stubs/2.7/functools.pyi similarity index 100% rename from stubs/2.7/functools.pyi rename to mypy/data/stubs/2.7/functools.pyi diff --git a/stubs/2.7/gc.pyi b/mypy/data/stubs/2.7/gc.pyi similarity index 100% rename from stubs/2.7/gc.pyi rename to mypy/data/stubs/2.7/gc.pyi diff --git a/stubs/2.7/getpass.pyi b/mypy/data/stubs/2.7/getpass.pyi similarity index 100% rename from stubs/2.7/getpass.pyi rename to mypy/data/stubs/2.7/getpass.pyi diff --git a/stubs/2.7/gettext.pyi b/mypy/data/stubs/2.7/gettext.pyi similarity index 100% rename from stubs/2.7/gettext.pyi rename to mypy/data/stubs/2.7/gettext.pyi diff --git a/stubs/2.7/glob.pyi b/mypy/data/stubs/2.7/glob.pyi similarity index 100% rename from stubs/2.7/glob.pyi rename to mypy/data/stubs/2.7/glob.pyi diff --git a/stubs/2.7/gzip.pyi b/mypy/data/stubs/2.7/gzip.pyi similarity index 100% rename from stubs/2.7/gzip.pyi rename to mypy/data/stubs/2.7/gzip.pyi diff --git a/stubs/2.7/hashlib.pyi b/mypy/data/stubs/2.7/hashlib.pyi similarity index 100% rename from stubs/2.7/hashlib.pyi rename to mypy/data/stubs/2.7/hashlib.pyi diff --git a/stubs/2.7/hmac.pyi b/mypy/data/stubs/2.7/hmac.pyi similarity index 100% rename from stubs/2.7/hmac.pyi rename to mypy/data/stubs/2.7/hmac.pyi diff --git a/stubs/2.7/htmlentitydefs.pyi b/mypy/data/stubs/2.7/htmlentitydefs.pyi similarity index 100% rename from stubs/2.7/htmlentitydefs.pyi rename to mypy/data/stubs/2.7/htmlentitydefs.pyi diff --git a/stubs/2.7/imp.pyi b/mypy/data/stubs/2.7/imp.pyi similarity index 100% rename from stubs/2.7/imp.pyi rename to mypy/data/stubs/2.7/imp.pyi diff --git a/stubs/2.7/importlib.pyi b/mypy/data/stubs/2.7/importlib.pyi similarity index 100% rename from stubs/2.7/importlib.pyi rename to mypy/data/stubs/2.7/importlib.pyi diff --git a/stubs/2.7/inspect.pyi b/mypy/data/stubs/2.7/inspect.pyi similarity index 100% rename from stubs/2.7/inspect.pyi rename to mypy/data/stubs/2.7/inspect.pyi diff --git a/stubs/2.7/io.pyi b/mypy/data/stubs/2.7/io.pyi similarity index 100% rename from stubs/2.7/io.pyi rename to mypy/data/stubs/2.7/io.pyi diff --git a/stubs/2.7/itertools.pyi b/mypy/data/stubs/2.7/itertools.pyi similarity index 100% rename from stubs/2.7/itertools.pyi rename to mypy/data/stubs/2.7/itertools.pyi diff --git a/stubs/2.7/json.pyi b/mypy/data/stubs/2.7/json.pyi similarity index 100% rename from stubs/2.7/json.pyi rename to mypy/data/stubs/2.7/json.pyi diff --git a/stubs/2.7/logging/__init__.pyi b/mypy/data/stubs/2.7/logging/__init__.pyi similarity index 100% rename from stubs/2.7/logging/__init__.pyi rename to mypy/data/stubs/2.7/logging/__init__.pyi diff --git a/stubs/2.7/logging/handlers.pyi b/mypy/data/stubs/2.7/logging/handlers.pyi similarity index 100% rename from stubs/2.7/logging/handlers.pyi rename to mypy/data/stubs/2.7/logging/handlers.pyi diff --git a/stubs/2.7/marshal.pyi b/mypy/data/stubs/2.7/marshal.pyi similarity index 100% rename from stubs/2.7/marshal.pyi rename to mypy/data/stubs/2.7/marshal.pyi diff --git a/stubs/2.7/math.pyi b/mypy/data/stubs/2.7/math.pyi similarity index 100% rename from stubs/2.7/math.pyi rename to mypy/data/stubs/2.7/math.pyi diff --git a/stubs/2.7/md5.pyi b/mypy/data/stubs/2.7/md5.pyi similarity index 100% rename from stubs/2.7/md5.pyi rename to mypy/data/stubs/2.7/md5.pyi diff --git a/stubs/2.7/numbers.pyi b/mypy/data/stubs/2.7/numbers.pyi similarity index 100% rename from stubs/2.7/numbers.pyi rename to mypy/data/stubs/2.7/numbers.pyi diff --git a/stubs/2.7/operator.pyi b/mypy/data/stubs/2.7/operator.pyi similarity index 100% rename from stubs/2.7/operator.pyi rename to mypy/data/stubs/2.7/operator.pyi diff --git a/stubs/2.7/os/__init__.pyi b/mypy/data/stubs/2.7/os/__init__.pyi similarity index 100% rename from stubs/2.7/os/__init__.pyi rename to mypy/data/stubs/2.7/os/__init__.pyi diff --git a/stubs/2.7/os/path.pyi b/mypy/data/stubs/2.7/os/path.pyi similarity index 100% rename from stubs/2.7/os/path.pyi rename to mypy/data/stubs/2.7/os/path.pyi diff --git a/stubs/2.7/pickle.pyi b/mypy/data/stubs/2.7/pickle.pyi similarity index 100% rename from stubs/2.7/pickle.pyi rename to mypy/data/stubs/2.7/pickle.pyi diff --git a/stubs/2.7/pipes.pyi b/mypy/data/stubs/2.7/pipes.pyi similarity index 100% rename from stubs/2.7/pipes.pyi rename to mypy/data/stubs/2.7/pipes.pyi diff --git a/stubs/2.7/pprint.pyi b/mypy/data/stubs/2.7/pprint.pyi similarity index 100% rename from stubs/2.7/pprint.pyi rename to mypy/data/stubs/2.7/pprint.pyi diff --git a/stubs/2.7/random.pyi b/mypy/data/stubs/2.7/random.pyi similarity index 100% rename from stubs/2.7/random.pyi rename to mypy/data/stubs/2.7/random.pyi diff --git a/stubs/2.7/re.pyi b/mypy/data/stubs/2.7/re.pyi similarity index 100% rename from stubs/2.7/re.pyi rename to mypy/data/stubs/2.7/re.pyi diff --git a/stubs/2.7/resource.pyi b/mypy/data/stubs/2.7/resource.pyi similarity index 100% rename from stubs/2.7/resource.pyi rename to mypy/data/stubs/2.7/resource.pyi diff --git a/stubs/2.7/select.pyi b/mypy/data/stubs/2.7/select.pyi similarity index 100% rename from stubs/2.7/select.pyi rename to mypy/data/stubs/2.7/select.pyi diff --git a/stubs/2.7/sha.pyi b/mypy/data/stubs/2.7/sha.pyi similarity index 100% rename from stubs/2.7/sha.pyi rename to mypy/data/stubs/2.7/sha.pyi diff --git a/stubs/2.7/shlex.pyi b/mypy/data/stubs/2.7/shlex.pyi similarity index 100% rename from stubs/2.7/shlex.pyi rename to mypy/data/stubs/2.7/shlex.pyi diff --git a/stubs/2.7/shutil.pyi b/mypy/data/stubs/2.7/shutil.pyi similarity index 100% rename from stubs/2.7/shutil.pyi rename to mypy/data/stubs/2.7/shutil.pyi diff --git a/stubs/2.7/signal.pyi b/mypy/data/stubs/2.7/signal.pyi similarity index 100% rename from stubs/2.7/signal.pyi rename to mypy/data/stubs/2.7/signal.pyi diff --git a/stubs/2.7/simplejson.pyi b/mypy/data/stubs/2.7/simplejson.pyi similarity index 100% rename from stubs/2.7/simplejson.pyi rename to mypy/data/stubs/2.7/simplejson.pyi diff --git a/stubs/2.7/smtplib.pyi b/mypy/data/stubs/2.7/smtplib.pyi similarity index 100% rename from stubs/2.7/smtplib.pyi rename to mypy/data/stubs/2.7/smtplib.pyi diff --git a/stubs/2.7/socket.pyi b/mypy/data/stubs/2.7/socket.pyi similarity index 100% rename from stubs/2.7/socket.pyi rename to mypy/data/stubs/2.7/socket.pyi diff --git a/stubs/2.7/stat.pyi b/mypy/data/stubs/2.7/stat.pyi similarity index 100% rename from stubs/2.7/stat.pyi rename to mypy/data/stubs/2.7/stat.pyi diff --git a/stubs/2.7/string.pyi b/mypy/data/stubs/2.7/string.pyi similarity index 100% rename from stubs/2.7/string.pyi rename to mypy/data/stubs/2.7/string.pyi diff --git a/stubs/2.7/struct.pyi b/mypy/data/stubs/2.7/struct.pyi similarity index 100% rename from stubs/2.7/struct.pyi rename to mypy/data/stubs/2.7/struct.pyi diff --git a/stubs/2.7/subprocess.pyi b/mypy/data/stubs/2.7/subprocess.pyi similarity index 100% rename from stubs/2.7/subprocess.pyi rename to mypy/data/stubs/2.7/subprocess.pyi diff --git a/stubs/2.7/sys.pyi b/mypy/data/stubs/2.7/sys.pyi similarity index 100% rename from stubs/2.7/sys.pyi rename to mypy/data/stubs/2.7/sys.pyi diff --git a/stubs/2.7/tarfile.pyi b/mypy/data/stubs/2.7/tarfile.pyi similarity index 100% rename from stubs/2.7/tarfile.pyi rename to mypy/data/stubs/2.7/tarfile.pyi diff --git a/stubs/2.7/tempfile.pyi b/mypy/data/stubs/2.7/tempfile.pyi similarity index 100% rename from stubs/2.7/tempfile.pyi rename to mypy/data/stubs/2.7/tempfile.pyi diff --git a/stubs/2.7/textwrap.pyi b/mypy/data/stubs/2.7/textwrap.pyi similarity index 100% rename from stubs/2.7/textwrap.pyi rename to mypy/data/stubs/2.7/textwrap.pyi diff --git a/stubs/2.7/thread.pyi b/mypy/data/stubs/2.7/thread.pyi similarity index 100% rename from stubs/2.7/thread.pyi rename to mypy/data/stubs/2.7/thread.pyi diff --git a/stubs/2.7/threading.pyi b/mypy/data/stubs/2.7/threading.pyi similarity index 100% rename from stubs/2.7/threading.pyi rename to mypy/data/stubs/2.7/threading.pyi diff --git a/stubs/2.7/time.pyi b/mypy/data/stubs/2.7/time.pyi similarity index 100% rename from stubs/2.7/time.pyi rename to mypy/data/stubs/2.7/time.pyi diff --git a/stubs/2.7/traceback.pyi b/mypy/data/stubs/2.7/traceback.pyi similarity index 100% rename from stubs/2.7/traceback.pyi rename to mypy/data/stubs/2.7/traceback.pyi diff --git a/stubs/2.7/types.pyi b/mypy/data/stubs/2.7/types.pyi similarity index 100% rename from stubs/2.7/types.pyi rename to mypy/data/stubs/2.7/types.pyi diff --git a/stubs/2.7/typing.pyi b/mypy/data/stubs/2.7/typing.pyi similarity index 100% rename from stubs/2.7/typing.pyi rename to mypy/data/stubs/2.7/typing.pyi diff --git a/stubs/2.7/unicodedata.pyi b/mypy/data/stubs/2.7/unicodedata.pyi similarity index 100% rename from stubs/2.7/unicodedata.pyi rename to mypy/data/stubs/2.7/unicodedata.pyi diff --git a/stubs/2.7/urllib.pyi b/mypy/data/stubs/2.7/urllib.pyi similarity index 100% rename from stubs/2.7/urllib.pyi rename to mypy/data/stubs/2.7/urllib.pyi diff --git a/stubs/2.7/urlparse.pyi b/mypy/data/stubs/2.7/urlparse.pyi similarity index 100% rename from stubs/2.7/urlparse.pyi rename to mypy/data/stubs/2.7/urlparse.pyi diff --git a/stubs/2.7/uuid.pyi b/mypy/data/stubs/2.7/uuid.pyi similarity index 100% rename from stubs/2.7/uuid.pyi rename to mypy/data/stubs/2.7/uuid.pyi diff --git a/stubs/3.2/distutils/__init__.pyi b/mypy/data/stubs/2.7/xml/__init__.pyi similarity index 100% rename from stubs/3.2/distutils/__init__.pyi rename to mypy/data/stubs/2.7/xml/__init__.pyi diff --git a/stubs/3.2/http/__init__.pyi b/mypy/data/stubs/2.7/xml/sax/__init__.pyi similarity index 100% rename from stubs/3.2/http/__init__.pyi rename to mypy/data/stubs/2.7/xml/sax/__init__.pyi diff --git a/stubs/2.7/xml/sax/handler.pyi b/mypy/data/stubs/2.7/xml/sax/handler.pyi similarity index 100% rename from stubs/2.7/xml/sax/handler.pyi rename to mypy/data/stubs/2.7/xml/sax/handler.pyi diff --git a/stubs/2.7/xml/sax/saxutils.pyi b/mypy/data/stubs/2.7/xml/sax/saxutils.pyi similarity index 100% rename from stubs/2.7/xml/sax/saxutils.pyi rename to mypy/data/stubs/2.7/xml/sax/saxutils.pyi diff --git a/stubs/2.7/xml/sax/xmlreader.pyi b/mypy/data/stubs/2.7/xml/sax/xmlreader.pyi similarity index 100% rename from stubs/2.7/xml/sax/xmlreader.pyi rename to mypy/data/stubs/2.7/xml/sax/xmlreader.pyi diff --git a/stubs/2.7/zlib.pyi b/mypy/data/stubs/2.7/zlib.pyi similarity index 100% rename from stubs/2.7/zlib.pyi rename to mypy/data/stubs/2.7/zlib.pyi diff --git a/stubs/3.2/__future__.pyi b/mypy/data/stubs/3.2/__future__.pyi similarity index 100% rename from stubs/3.2/__future__.pyi rename to mypy/data/stubs/3.2/__future__.pyi diff --git a/stubs/3.2/_dummy_thread.pyi b/mypy/data/stubs/3.2/_dummy_thread.pyi similarity index 100% rename from stubs/3.2/_dummy_thread.pyi rename to mypy/data/stubs/3.2/_dummy_thread.pyi diff --git a/stubs/3.2/_io.pyi b/mypy/data/stubs/3.2/_io.pyi similarity index 100% rename from stubs/3.2/_io.pyi rename to mypy/data/stubs/3.2/_io.pyi diff --git a/stubs/3.2/_locale.pyi b/mypy/data/stubs/3.2/_locale.pyi similarity index 100% rename from stubs/3.2/_locale.pyi rename to mypy/data/stubs/3.2/_locale.pyi diff --git a/stubs/3.2/_posixsubprocess.pyi b/mypy/data/stubs/3.2/_posixsubprocess.pyi similarity index 100% rename from stubs/3.2/_posixsubprocess.pyi rename to mypy/data/stubs/3.2/_posixsubprocess.pyi diff --git a/stubs/3.2/_random.pyi b/mypy/data/stubs/3.2/_random.pyi similarity index 100% rename from stubs/3.2/_random.pyi rename to mypy/data/stubs/3.2/_random.pyi diff --git a/stubs/3.2/_subprocess.pyi b/mypy/data/stubs/3.2/_subprocess.pyi similarity index 100% rename from stubs/3.2/_subprocess.pyi rename to mypy/data/stubs/3.2/_subprocess.pyi diff --git a/stubs/3.2/_thread.pyi b/mypy/data/stubs/3.2/_thread.pyi similarity index 100% rename from stubs/3.2/_thread.pyi rename to mypy/data/stubs/3.2/_thread.pyi diff --git a/stubs/3.2/abc.pyi b/mypy/data/stubs/3.2/abc.pyi similarity index 100% rename from stubs/3.2/abc.pyi rename to mypy/data/stubs/3.2/abc.pyi diff --git a/stubs/3.2/argparse.pyi b/mypy/data/stubs/3.2/argparse.pyi similarity index 100% rename from stubs/3.2/argparse.pyi rename to mypy/data/stubs/3.2/argparse.pyi diff --git a/stubs/3.2/array.pyi b/mypy/data/stubs/3.2/array.pyi similarity index 100% rename from stubs/3.2/array.pyi rename to mypy/data/stubs/3.2/array.pyi diff --git a/stubs/3.2/atexit.pyi b/mypy/data/stubs/3.2/atexit.pyi similarity index 100% rename from stubs/3.2/atexit.pyi rename to mypy/data/stubs/3.2/atexit.pyi diff --git a/stubs/3.2/base64.pyi b/mypy/data/stubs/3.2/base64.pyi similarity index 100% rename from stubs/3.2/base64.pyi rename to mypy/data/stubs/3.2/base64.pyi diff --git a/stubs/3.2/binascii.pyi b/mypy/data/stubs/3.2/binascii.pyi similarity index 100% rename from stubs/3.2/binascii.pyi rename to mypy/data/stubs/3.2/binascii.pyi diff --git a/stubs/3.2/bisect.pyi b/mypy/data/stubs/3.2/bisect.pyi similarity index 100% rename from stubs/3.2/bisect.pyi rename to mypy/data/stubs/3.2/bisect.pyi diff --git a/stubs/3.2/builtins.pyi b/mypy/data/stubs/3.2/builtins.pyi similarity index 100% rename from stubs/3.2/builtins.pyi rename to mypy/data/stubs/3.2/builtins.pyi diff --git a/stubs/3.2/bz2.pyi b/mypy/data/stubs/3.2/bz2.pyi similarity index 100% rename from stubs/3.2/bz2.pyi rename to mypy/data/stubs/3.2/bz2.pyi diff --git a/stubs/3.2/calendar.pyi b/mypy/data/stubs/3.2/calendar.pyi similarity index 100% rename from stubs/3.2/calendar.pyi rename to mypy/data/stubs/3.2/calendar.pyi diff --git a/stubs/3.2/cgi.pyi b/mypy/data/stubs/3.2/cgi.pyi similarity index 100% rename from stubs/3.2/cgi.pyi rename to mypy/data/stubs/3.2/cgi.pyi diff --git a/stubs/3.2/codecs.pyi b/mypy/data/stubs/3.2/codecs.pyi similarity index 100% rename from stubs/3.2/codecs.pyi rename to mypy/data/stubs/3.2/codecs.pyi diff --git a/stubs/3.2/collections.pyi b/mypy/data/stubs/3.2/collections.pyi similarity index 100% rename from stubs/3.2/collections.pyi rename to mypy/data/stubs/3.2/collections.pyi diff --git a/stubs/3.2/contextlib.pyi b/mypy/data/stubs/3.2/contextlib.pyi similarity index 100% rename from stubs/3.2/contextlib.pyi rename to mypy/data/stubs/3.2/contextlib.pyi diff --git a/stubs/3.2/copy.pyi b/mypy/data/stubs/3.2/copy.pyi similarity index 100% rename from stubs/3.2/copy.pyi rename to mypy/data/stubs/3.2/copy.pyi diff --git a/stubs/3.2/csv.pyi b/mypy/data/stubs/3.2/csv.pyi similarity index 100% rename from stubs/3.2/csv.pyi rename to mypy/data/stubs/3.2/csv.pyi diff --git a/stubs/3.2/datetime.pyi b/mypy/data/stubs/3.2/datetime.pyi similarity index 100% rename from stubs/3.2/datetime.pyi rename to mypy/data/stubs/3.2/datetime.pyi diff --git a/stubs/3.2/decimal.pyi b/mypy/data/stubs/3.2/decimal.pyi similarity index 100% rename from stubs/3.2/decimal.pyi rename to mypy/data/stubs/3.2/decimal.pyi diff --git a/stubs/3.2/difflib.pyi b/mypy/data/stubs/3.2/difflib.pyi similarity index 100% rename from stubs/3.2/difflib.pyi rename to mypy/data/stubs/3.2/difflib.pyi diff --git a/stubs/3.2/urllib/__init__.pyi b/mypy/data/stubs/3.2/distutils/__init__.pyi similarity index 100% rename from stubs/3.2/urllib/__init__.pyi rename to mypy/data/stubs/3.2/distutils/__init__.pyi diff --git a/stubs/3.2/distutils/errors.pyi b/mypy/data/stubs/3.2/distutils/errors.pyi similarity index 100% rename from stubs/3.2/distutils/errors.pyi rename to mypy/data/stubs/3.2/distutils/errors.pyi diff --git a/stubs/3.2/distutils/spawn.pyi b/mypy/data/stubs/3.2/distutils/spawn.pyi similarity index 100% rename from stubs/3.2/distutils/spawn.pyi rename to mypy/data/stubs/3.2/distutils/spawn.pyi diff --git a/stubs/3.2/doctest.pyi b/mypy/data/stubs/3.2/doctest.pyi similarity index 100% rename from stubs/3.2/doctest.pyi rename to mypy/data/stubs/3.2/doctest.pyi diff --git a/stubs/3.2/email/__init__.pyi b/mypy/data/stubs/3.2/email/__init__.pyi similarity index 100% rename from stubs/3.2/email/__init__.pyi rename to mypy/data/stubs/3.2/email/__init__.pyi diff --git a/stubs/3.2/email/_header_value_parser.pyi b/mypy/data/stubs/3.2/email/_header_value_parser.pyi similarity index 100% rename from stubs/3.2/email/_header_value_parser.pyi rename to mypy/data/stubs/3.2/email/_header_value_parser.pyi diff --git a/stubs/3.2/email/_parseaddr.pyi b/mypy/data/stubs/3.2/email/_parseaddr.pyi similarity index 100% rename from stubs/3.2/email/_parseaddr.pyi rename to mypy/data/stubs/3.2/email/_parseaddr.pyi diff --git a/stubs/3.2/email/_policybase.pyi b/mypy/data/stubs/3.2/email/_policybase.pyi similarity index 100% rename from stubs/3.2/email/_policybase.pyi rename to mypy/data/stubs/3.2/email/_policybase.pyi diff --git a/stubs/3.2/email/base64mime.pyi b/mypy/data/stubs/3.2/email/base64mime.pyi similarity index 100% rename from stubs/3.2/email/base64mime.pyi rename to mypy/data/stubs/3.2/email/base64mime.pyi diff --git a/stubs/3.2/email/charset.pyi b/mypy/data/stubs/3.2/email/charset.pyi similarity index 100% rename from stubs/3.2/email/charset.pyi rename to mypy/data/stubs/3.2/email/charset.pyi diff --git a/stubs/3.2/email/contentmanager.pyi b/mypy/data/stubs/3.2/email/contentmanager.pyi similarity index 100% rename from stubs/3.2/email/contentmanager.pyi rename to mypy/data/stubs/3.2/email/contentmanager.pyi diff --git a/stubs/3.2/email/encoders.pyi b/mypy/data/stubs/3.2/email/encoders.pyi similarity index 100% rename from stubs/3.2/email/encoders.pyi rename to mypy/data/stubs/3.2/email/encoders.pyi diff --git a/stubs/3.2/email/errors.pyi b/mypy/data/stubs/3.2/email/errors.pyi similarity index 100% rename from stubs/3.2/email/errors.pyi rename to mypy/data/stubs/3.2/email/errors.pyi diff --git a/stubs/3.2/email/feedparser.pyi b/mypy/data/stubs/3.2/email/feedparser.pyi similarity index 100% rename from stubs/3.2/email/feedparser.pyi rename to mypy/data/stubs/3.2/email/feedparser.pyi diff --git a/stubs/3.2/email/generator.pyi b/mypy/data/stubs/3.2/email/generator.pyi similarity index 100% rename from stubs/3.2/email/generator.pyi rename to mypy/data/stubs/3.2/email/generator.pyi diff --git a/stubs/3.2/email/header.pyi b/mypy/data/stubs/3.2/email/header.pyi similarity index 100% rename from stubs/3.2/email/header.pyi rename to mypy/data/stubs/3.2/email/header.pyi diff --git a/stubs/3.2/email/headerregistry.pyi b/mypy/data/stubs/3.2/email/headerregistry.pyi similarity index 100% rename from stubs/3.2/email/headerregistry.pyi rename to mypy/data/stubs/3.2/email/headerregistry.pyi diff --git a/stubs/3.2/email/iterators.pyi b/mypy/data/stubs/3.2/email/iterators.pyi similarity index 100% rename from stubs/3.2/email/iterators.pyi rename to mypy/data/stubs/3.2/email/iterators.pyi diff --git a/stubs/3.2/email/message.pyi b/mypy/data/stubs/3.2/email/message.pyi similarity index 100% rename from stubs/3.2/email/message.pyi rename to mypy/data/stubs/3.2/email/message.pyi diff --git a/stubs/3.2/email/mime/__init__.pyi b/mypy/data/stubs/3.2/email/mime/__init__.pyi similarity index 100% rename from stubs/3.2/email/mime/__init__.pyi rename to mypy/data/stubs/3.2/email/mime/__init__.pyi diff --git a/stubs/3.2/email/mime/application.pyi b/mypy/data/stubs/3.2/email/mime/application.pyi similarity index 100% rename from stubs/3.2/email/mime/application.pyi rename to mypy/data/stubs/3.2/email/mime/application.pyi diff --git a/stubs/3.2/email/mime/audio.pyi b/mypy/data/stubs/3.2/email/mime/audio.pyi similarity index 100% rename from stubs/3.2/email/mime/audio.pyi rename to mypy/data/stubs/3.2/email/mime/audio.pyi diff --git a/stubs/3.2/email/mime/base.pyi b/mypy/data/stubs/3.2/email/mime/base.pyi similarity index 100% rename from stubs/3.2/email/mime/base.pyi rename to mypy/data/stubs/3.2/email/mime/base.pyi diff --git a/stubs/3.2/email/mime/image.pyi b/mypy/data/stubs/3.2/email/mime/image.pyi similarity index 100% rename from stubs/3.2/email/mime/image.pyi rename to mypy/data/stubs/3.2/email/mime/image.pyi diff --git a/stubs/3.2/email/mime/message.pyi b/mypy/data/stubs/3.2/email/mime/message.pyi similarity index 100% rename from stubs/3.2/email/mime/message.pyi rename to mypy/data/stubs/3.2/email/mime/message.pyi diff --git a/stubs/3.2/email/mime/multipart.pyi b/mypy/data/stubs/3.2/email/mime/multipart.pyi similarity index 100% rename from stubs/3.2/email/mime/multipart.pyi rename to mypy/data/stubs/3.2/email/mime/multipart.pyi diff --git a/stubs/3.2/email/mime/nonmultipart.pyi b/mypy/data/stubs/3.2/email/mime/nonmultipart.pyi similarity index 100% rename from stubs/3.2/email/mime/nonmultipart.pyi rename to mypy/data/stubs/3.2/email/mime/nonmultipart.pyi diff --git a/stubs/3.2/email/mime/text.pyi b/mypy/data/stubs/3.2/email/mime/text.pyi similarity index 100% rename from stubs/3.2/email/mime/text.pyi rename to mypy/data/stubs/3.2/email/mime/text.pyi diff --git a/stubs/3.2/email/parser.pyi b/mypy/data/stubs/3.2/email/parser.pyi similarity index 100% rename from stubs/3.2/email/parser.pyi rename to mypy/data/stubs/3.2/email/parser.pyi diff --git a/stubs/3.2/email/policy.pyi b/mypy/data/stubs/3.2/email/policy.pyi similarity index 100% rename from stubs/3.2/email/policy.pyi rename to mypy/data/stubs/3.2/email/policy.pyi diff --git a/stubs/3.2/email/quoprimime.pyi b/mypy/data/stubs/3.2/email/quoprimime.pyi similarity index 100% rename from stubs/3.2/email/quoprimime.pyi rename to mypy/data/stubs/3.2/email/quoprimime.pyi diff --git a/stubs/3.2/email/utils.pyi b/mypy/data/stubs/3.2/email/utils.pyi similarity index 100% rename from stubs/3.2/email/utils.pyi rename to mypy/data/stubs/3.2/email/utils.pyi diff --git a/stubs/3.2/encodings/__init__.pyi b/mypy/data/stubs/3.2/encodings/__init__.pyi similarity index 100% rename from stubs/3.2/encodings/__init__.pyi rename to mypy/data/stubs/3.2/encodings/__init__.pyi diff --git a/stubs/3.2/encodings/utf_8.pyi b/mypy/data/stubs/3.2/encodings/utf_8.pyi similarity index 100% rename from stubs/3.2/encodings/utf_8.pyi rename to mypy/data/stubs/3.2/encodings/utf_8.pyi diff --git a/stubs/3.2/errno.pyi b/mypy/data/stubs/3.2/errno.pyi similarity index 100% rename from stubs/3.2/errno.pyi rename to mypy/data/stubs/3.2/errno.pyi diff --git a/stubs/3.2/fcntl.pyi b/mypy/data/stubs/3.2/fcntl.pyi similarity index 100% rename from stubs/3.2/fcntl.pyi rename to mypy/data/stubs/3.2/fcntl.pyi diff --git a/stubs/3.2/fnmatch.pyi b/mypy/data/stubs/3.2/fnmatch.pyi similarity index 100% rename from stubs/3.2/fnmatch.pyi rename to mypy/data/stubs/3.2/fnmatch.pyi diff --git a/stubs/3.2/functools.pyi b/mypy/data/stubs/3.2/functools.pyi similarity index 100% rename from stubs/3.2/functools.pyi rename to mypy/data/stubs/3.2/functools.pyi diff --git a/stubs/3.2/gc.pyi b/mypy/data/stubs/3.2/gc.pyi similarity index 100% rename from stubs/3.2/gc.pyi rename to mypy/data/stubs/3.2/gc.pyi diff --git a/stubs/3.2/getopt.pyi b/mypy/data/stubs/3.2/getopt.pyi similarity index 100% rename from stubs/3.2/getopt.pyi rename to mypy/data/stubs/3.2/getopt.pyi diff --git a/stubs/3.2/getpass.pyi b/mypy/data/stubs/3.2/getpass.pyi similarity index 100% rename from stubs/3.2/getpass.pyi rename to mypy/data/stubs/3.2/getpass.pyi diff --git a/stubs/3.2/gettext.pyi b/mypy/data/stubs/3.2/gettext.pyi similarity index 100% rename from stubs/3.2/gettext.pyi rename to mypy/data/stubs/3.2/gettext.pyi diff --git a/stubs/3.2/glob.pyi b/mypy/data/stubs/3.2/glob.pyi similarity index 100% rename from stubs/3.2/glob.pyi rename to mypy/data/stubs/3.2/glob.pyi diff --git a/stubs/3.2/grp.pyi b/mypy/data/stubs/3.2/grp.pyi similarity index 100% rename from stubs/3.2/grp.pyi rename to mypy/data/stubs/3.2/grp.pyi diff --git a/stubs/3.2/hashlib.pyi b/mypy/data/stubs/3.2/hashlib.pyi similarity index 100% rename from stubs/3.2/hashlib.pyi rename to mypy/data/stubs/3.2/hashlib.pyi diff --git a/stubs/3.2/heapq.pyi b/mypy/data/stubs/3.2/heapq.pyi similarity index 100% rename from stubs/3.2/heapq.pyi rename to mypy/data/stubs/3.2/heapq.pyi diff --git a/stubs/3.2/xml/__init__.pyi b/mypy/data/stubs/3.2/http/__init__.pyi similarity index 100% rename from stubs/3.2/xml/__init__.pyi rename to mypy/data/stubs/3.2/http/__init__.pyi diff --git a/stubs/3.2/http/client.pyi b/mypy/data/stubs/3.2/http/client.pyi similarity index 100% rename from stubs/3.2/http/client.pyi rename to mypy/data/stubs/3.2/http/client.pyi diff --git a/stubs/3.2/http/cookiejar.pyi b/mypy/data/stubs/3.2/http/cookiejar.pyi similarity index 100% rename from stubs/3.2/http/cookiejar.pyi rename to mypy/data/stubs/3.2/http/cookiejar.pyi diff --git a/stubs/3.2/imp.pyi b/mypy/data/stubs/3.2/imp.pyi similarity index 100% rename from stubs/3.2/imp.pyi rename to mypy/data/stubs/3.2/imp.pyi diff --git a/stubs/3.2/importlib.pyi b/mypy/data/stubs/3.2/importlib.pyi similarity index 100% rename from stubs/3.2/importlib.pyi rename to mypy/data/stubs/3.2/importlib.pyi diff --git a/stubs/3.2/inspect.pyi b/mypy/data/stubs/3.2/inspect.pyi similarity index 100% rename from stubs/3.2/inspect.pyi rename to mypy/data/stubs/3.2/inspect.pyi diff --git a/stubs/3.2/io.pyi b/mypy/data/stubs/3.2/io.pyi similarity index 100% rename from stubs/3.2/io.pyi rename to mypy/data/stubs/3.2/io.pyi diff --git a/stubs/3.2/itertools.pyi b/mypy/data/stubs/3.2/itertools.pyi similarity index 100% rename from stubs/3.2/itertools.pyi rename to mypy/data/stubs/3.2/itertools.pyi diff --git a/stubs/3.2/json.pyi b/mypy/data/stubs/3.2/json.pyi similarity index 100% rename from stubs/3.2/json.pyi rename to mypy/data/stubs/3.2/json.pyi diff --git a/stubs/3.2/linecache.pyi b/mypy/data/stubs/3.2/linecache.pyi similarity index 100% rename from stubs/3.2/linecache.pyi rename to mypy/data/stubs/3.2/linecache.pyi diff --git a/stubs/3.2/locale.pyi b/mypy/data/stubs/3.2/locale.pyi similarity index 100% rename from stubs/3.2/locale.pyi rename to mypy/data/stubs/3.2/locale.pyi diff --git a/stubs/3.2/logging/__init__.pyi b/mypy/data/stubs/3.2/logging/__init__.pyi similarity index 100% rename from stubs/3.2/logging/__init__.pyi rename to mypy/data/stubs/3.2/logging/__init__.pyi diff --git a/stubs/3.2/logging/handlers.pyi b/mypy/data/stubs/3.2/logging/handlers.pyi similarity index 100% rename from stubs/3.2/logging/handlers.pyi rename to mypy/data/stubs/3.2/logging/handlers.pyi diff --git a/stubs/3.2/math.pyi b/mypy/data/stubs/3.2/math.pyi similarity index 100% rename from stubs/3.2/math.pyi rename to mypy/data/stubs/3.2/math.pyi diff --git a/stubs/3.2/msvcrt.pyi b/mypy/data/stubs/3.2/msvcrt.pyi similarity index 100% rename from stubs/3.2/msvcrt.pyi rename to mypy/data/stubs/3.2/msvcrt.pyi diff --git a/stubs/3.2/multiprocessing/__init__.pyi b/mypy/data/stubs/3.2/multiprocessing/__init__.pyi similarity index 100% rename from stubs/3.2/multiprocessing/__init__.pyi rename to mypy/data/stubs/3.2/multiprocessing/__init__.pyi diff --git a/stubs/3.2/multiprocessing/managers.pyi b/mypy/data/stubs/3.2/multiprocessing/managers.pyi similarity index 100% rename from stubs/3.2/multiprocessing/managers.pyi rename to mypy/data/stubs/3.2/multiprocessing/managers.pyi diff --git a/stubs/3.2/multiprocessing/pool.pyi b/mypy/data/stubs/3.2/multiprocessing/pool.pyi similarity index 100% rename from stubs/3.2/multiprocessing/pool.pyi rename to mypy/data/stubs/3.2/multiprocessing/pool.pyi diff --git a/stubs/3.2/operator.pyi b/mypy/data/stubs/3.2/operator.pyi similarity index 100% rename from stubs/3.2/operator.pyi rename to mypy/data/stubs/3.2/operator.pyi diff --git a/stubs/3.2/os/__init__.pyi b/mypy/data/stubs/3.2/os/__init__.pyi similarity index 100% rename from stubs/3.2/os/__init__.pyi rename to mypy/data/stubs/3.2/os/__init__.pyi diff --git a/stubs/3.2/os/path.pyi b/mypy/data/stubs/3.2/os/path.pyi similarity index 100% rename from stubs/3.2/os/path.pyi rename to mypy/data/stubs/3.2/os/path.pyi diff --git a/stubs/3.2/pickle.pyi b/mypy/data/stubs/3.2/pickle.pyi similarity index 100% rename from stubs/3.2/pickle.pyi rename to mypy/data/stubs/3.2/pickle.pyi diff --git a/stubs/3.2/pipes.pyi b/mypy/data/stubs/3.2/pipes.pyi similarity index 100% rename from stubs/3.2/pipes.pyi rename to mypy/data/stubs/3.2/pipes.pyi diff --git a/mypy/data/stubs/3.2/platform.pyi b/mypy/data/stubs/3.2/platform.pyi new file mode 100644 index 000000000000..3a614400e9c0 --- /dev/null +++ b/mypy/data/stubs/3.2/platform.pyi @@ -0,0 +1,35 @@ +# Stubs for platform (Python 3.5) + +from typing import Tuple, NamedTuple + +from os import devnull as DEV_NULL + +def libc_ver(executable: str = ..., lib: str = '', version: str = '', chunksize: int = 16384) -> Tuple[str, str]: ... +def linux_distribution(distname: str = '', version: str = '', id: str = '', supported_dists: Tuple[str, ...] = ..., full_distribution_name: bool = True) -> Tuple[str, str, str]: ... +def dist(distname: str = '', version: str = '', id: str = '', supported_dists: Tuple[str, ...] = ...) -> Tuple[str, str, str]: ... +from os import popen +def win32_ver(release: str = '', version: str = '', csd: str = '', ptype: str = '') -> Tuple[str, str, str, str]: ... +def mac_ver(release: str = '', versioninfo: Tuple[str, str, str] = ..., machine: str = '') -> Tuple[str, Tuple[str, str, str], str]: ... +def java_ver(release: str = '', vendor: str = '', vminfo: Tuple[str, str, str] = ..., osinfo: Tuple[str, str, str] = ...) -> Tuple[str, str, Tuple[str, str, str], Tuple[str, str, str]]: ... +def system_alias(system: str, release: str, version: str) -> Tuple[str, str, str]: ... +def architecture(executable: str = ..., bits: str = '', linkage: str = '') -> Tuple[str, str]: ... + +uname_result = NamedTuple('uname_result', [('system', str), ('node', str), ('release', str), ('version', str), ('machine', str), ('processor', str)]) + +def uname() -> uname_result: ... +def system() -> str: ... +def node() -> str: ... +def release() -> str: ... +def version() -> str: ... +def machine() -> str: ... +def processor() -> str: ... + +def python_implementation() -> str: ... +def python_version() -> str: ... +def python_version_tuple() -> Tuple[str, str, str]: ... +def python_branch() -> str: ... +def python_revision() -> str: ... +def python_build() -> Tuple[str, str]: ... +def python_compiler() -> str: ... + +def platform(aliased: bool = False, terse: bool = False) -> str: ... diff --git a/stubs/3.2/posix.pyi b/mypy/data/stubs/3.2/posix.pyi similarity index 100% rename from stubs/3.2/posix.pyi rename to mypy/data/stubs/3.2/posix.pyi diff --git a/stubs/3.2/posixpath.pyi b/mypy/data/stubs/3.2/posixpath.pyi similarity index 100% rename from stubs/3.2/posixpath.pyi rename to mypy/data/stubs/3.2/posixpath.pyi diff --git a/stubs/3.2/pprint.pyi b/mypy/data/stubs/3.2/pprint.pyi similarity index 100% rename from stubs/3.2/pprint.pyi rename to mypy/data/stubs/3.2/pprint.pyi diff --git a/stubs/3.2/pwd.pyi b/mypy/data/stubs/3.2/pwd.pyi similarity index 100% rename from stubs/3.2/pwd.pyi rename to mypy/data/stubs/3.2/pwd.pyi diff --git a/stubs/3.2/queue.pyi b/mypy/data/stubs/3.2/queue.pyi similarity index 100% rename from stubs/3.2/queue.pyi rename to mypy/data/stubs/3.2/queue.pyi diff --git a/stubs/3.2/random.pyi b/mypy/data/stubs/3.2/random.pyi similarity index 100% rename from stubs/3.2/random.pyi rename to mypy/data/stubs/3.2/random.pyi diff --git a/stubs/3.2/re.pyi b/mypy/data/stubs/3.2/re.pyi similarity index 100% rename from stubs/3.2/re.pyi rename to mypy/data/stubs/3.2/re.pyi diff --git a/stubs/3.2/resource.pyi b/mypy/data/stubs/3.2/resource.pyi similarity index 100% rename from stubs/3.2/resource.pyi rename to mypy/data/stubs/3.2/resource.pyi diff --git a/stubs/3.2/select.pyi b/mypy/data/stubs/3.2/select.pyi similarity index 100% rename from stubs/3.2/select.pyi rename to mypy/data/stubs/3.2/select.pyi diff --git a/stubs/3.2/shlex.pyi b/mypy/data/stubs/3.2/shlex.pyi similarity index 100% rename from stubs/3.2/shlex.pyi rename to mypy/data/stubs/3.2/shlex.pyi diff --git a/stubs/3.2/shutil.pyi b/mypy/data/stubs/3.2/shutil.pyi similarity index 100% rename from stubs/3.2/shutil.pyi rename to mypy/data/stubs/3.2/shutil.pyi diff --git a/stubs/3.2/signal.pyi b/mypy/data/stubs/3.2/signal.pyi similarity index 100% rename from stubs/3.2/signal.pyi rename to mypy/data/stubs/3.2/signal.pyi diff --git a/stubs/3.2/smtplib.pyi b/mypy/data/stubs/3.2/smtplib.pyi similarity index 100% rename from stubs/3.2/smtplib.pyi rename to mypy/data/stubs/3.2/smtplib.pyi diff --git a/stubs/3.2/socket.pyi b/mypy/data/stubs/3.2/socket.pyi similarity index 100% rename from stubs/3.2/socket.pyi rename to mypy/data/stubs/3.2/socket.pyi diff --git a/stubs/3.2/socketserver.pyi b/mypy/data/stubs/3.2/socketserver.pyi similarity index 100% rename from stubs/3.2/socketserver.pyi rename to mypy/data/stubs/3.2/socketserver.pyi diff --git a/stubs/3.2/ssl.pyi b/mypy/data/stubs/3.2/ssl.pyi similarity index 100% rename from stubs/3.2/ssl.pyi rename to mypy/data/stubs/3.2/ssl.pyi diff --git a/stubs/3.2/stat.pyi b/mypy/data/stubs/3.2/stat.pyi similarity index 100% rename from stubs/3.2/stat.pyi rename to mypy/data/stubs/3.2/stat.pyi diff --git a/stubs/3.2/string.pyi b/mypy/data/stubs/3.2/string.pyi similarity index 100% rename from stubs/3.2/string.pyi rename to mypy/data/stubs/3.2/string.pyi diff --git a/stubs/3.2/struct.pyi b/mypy/data/stubs/3.2/struct.pyi similarity index 100% rename from stubs/3.2/struct.pyi rename to mypy/data/stubs/3.2/struct.pyi diff --git a/stubs/3.2/subprocess.pyi b/mypy/data/stubs/3.2/subprocess.pyi similarity index 100% rename from stubs/3.2/subprocess.pyi rename to mypy/data/stubs/3.2/subprocess.pyi diff --git a/stubs/3.2/sys.pyi b/mypy/data/stubs/3.2/sys.pyi similarity index 100% rename from stubs/3.2/sys.pyi rename to mypy/data/stubs/3.2/sys.pyi diff --git a/stubs/3.2/sysconfig.pyi b/mypy/data/stubs/3.2/sysconfig.pyi similarity index 100% rename from stubs/3.2/sysconfig.pyi rename to mypy/data/stubs/3.2/sysconfig.pyi diff --git a/stubs/3.2/tarfile.pyi b/mypy/data/stubs/3.2/tarfile.pyi similarity index 100% rename from stubs/3.2/tarfile.pyi rename to mypy/data/stubs/3.2/tarfile.pyi diff --git a/stubs/3.2/tempfile.pyi b/mypy/data/stubs/3.2/tempfile.pyi similarity index 100% rename from stubs/3.2/tempfile.pyi rename to mypy/data/stubs/3.2/tempfile.pyi diff --git a/stubs/3.2/textwrap.pyi b/mypy/data/stubs/3.2/textwrap.pyi similarity index 100% rename from stubs/3.2/textwrap.pyi rename to mypy/data/stubs/3.2/textwrap.pyi diff --git a/stubs/3.2/threading.pyi b/mypy/data/stubs/3.2/threading.pyi similarity index 100% rename from stubs/3.2/threading.pyi rename to mypy/data/stubs/3.2/threading.pyi diff --git a/stubs/3.2/time.pyi b/mypy/data/stubs/3.2/time.pyi similarity index 100% rename from stubs/3.2/time.pyi rename to mypy/data/stubs/3.2/time.pyi diff --git a/stubs/3.2/token.pyi b/mypy/data/stubs/3.2/token.pyi similarity index 100% rename from stubs/3.2/token.pyi rename to mypy/data/stubs/3.2/token.pyi diff --git a/stubs/3.2/traceback.pyi b/mypy/data/stubs/3.2/traceback.pyi similarity index 100% rename from stubs/3.2/traceback.pyi rename to mypy/data/stubs/3.2/traceback.pyi diff --git a/stubs/3.2/types.pyi b/mypy/data/stubs/3.2/types.pyi similarity index 100% rename from stubs/3.2/types.pyi rename to mypy/data/stubs/3.2/types.pyi diff --git a/stubs/3.2/typing.pyi b/mypy/data/stubs/3.2/typing.pyi similarity index 100% rename from stubs/3.2/typing.pyi rename to mypy/data/stubs/3.2/typing.pyi diff --git a/stubs/3.2/unicodedata.pyi b/mypy/data/stubs/3.2/unicodedata.pyi similarity index 100% rename from stubs/3.2/unicodedata.pyi rename to mypy/data/stubs/3.2/unicodedata.pyi diff --git a/stubs/3.2/unittest.pyi b/mypy/data/stubs/3.2/unittest.pyi similarity index 100% rename from stubs/3.2/unittest.pyi rename to mypy/data/stubs/3.2/unittest.pyi diff --git a/stubs/3.2/xml/etree/__init__.pyi b/mypy/data/stubs/3.2/urllib/__init__.pyi similarity index 100% rename from stubs/3.2/xml/etree/__init__.pyi rename to mypy/data/stubs/3.2/urllib/__init__.pyi diff --git a/stubs/3.2/urllib/error.pyi b/mypy/data/stubs/3.2/urllib/error.pyi similarity index 100% rename from stubs/3.2/urllib/error.pyi rename to mypy/data/stubs/3.2/urllib/error.pyi diff --git a/stubs/3.2/urllib/parse.pyi b/mypy/data/stubs/3.2/urllib/parse.pyi similarity index 100% rename from stubs/3.2/urllib/parse.pyi rename to mypy/data/stubs/3.2/urllib/parse.pyi diff --git a/stubs/3.2/urllib/request.pyi b/mypy/data/stubs/3.2/urllib/request.pyi similarity index 100% rename from stubs/3.2/urllib/request.pyi rename to mypy/data/stubs/3.2/urllib/request.pyi diff --git a/stubs/3.2/uuid.pyi b/mypy/data/stubs/3.2/uuid.pyi similarity index 100% rename from stubs/3.2/uuid.pyi rename to mypy/data/stubs/3.2/uuid.pyi diff --git a/stubs/3.2/warnings.pyi b/mypy/data/stubs/3.2/warnings.pyi similarity index 100% rename from stubs/3.2/warnings.pyi rename to mypy/data/stubs/3.2/warnings.pyi diff --git a/stubs/3.2/weakref.pyi b/mypy/data/stubs/3.2/weakref.pyi similarity index 100% rename from stubs/3.2/weakref.pyi rename to mypy/data/stubs/3.2/weakref.pyi diff --git a/stubs/3.2/webbrowser.pyi b/mypy/data/stubs/3.2/webbrowser.pyi similarity index 100% rename from stubs/3.2/webbrowser.pyi rename to mypy/data/stubs/3.2/webbrowser.pyi diff --git a/stubs/third-party-2.7/Crypto/__init__.pyi b/mypy/data/stubs/3.2/xml/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/Crypto/__init__.pyi rename to mypy/data/stubs/3.2/xml/__init__.pyi diff --git a/stubs/3.2/xml/etree/ElementInclude.pyi b/mypy/data/stubs/3.2/xml/etree/ElementInclude.pyi similarity index 100% rename from stubs/3.2/xml/etree/ElementInclude.pyi rename to mypy/data/stubs/3.2/xml/etree/ElementInclude.pyi diff --git a/stubs/3.2/xml/etree/ElementPath.pyi b/mypy/data/stubs/3.2/xml/etree/ElementPath.pyi similarity index 100% rename from stubs/3.2/xml/etree/ElementPath.pyi rename to mypy/data/stubs/3.2/xml/etree/ElementPath.pyi diff --git a/stubs/3.2/xml/etree/ElementTree.pyi b/mypy/data/stubs/3.2/xml/etree/ElementTree.pyi similarity index 100% rename from stubs/3.2/xml/etree/ElementTree.pyi rename to mypy/data/stubs/3.2/xml/etree/ElementTree.pyi diff --git a/stubs/third-party-2.7/OpenSSL/__init__.pyi b/mypy/data/stubs/3.2/xml/etree/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/OpenSSL/__init__.pyi rename to mypy/data/stubs/3.2/xml/etree/__init__.pyi diff --git a/stubs/3.2/xml/etree/cElementTree.pyi b/mypy/data/stubs/3.2/xml/etree/cElementTree.pyi similarity index 100% rename from stubs/3.2/xml/etree/cElementTree.pyi rename to mypy/data/stubs/3.2/xml/etree/cElementTree.pyi diff --git a/stubs/3.2/zipfile.pyi b/mypy/data/stubs/3.2/zipfile.pyi similarity index 100% rename from stubs/3.2/zipfile.pyi rename to mypy/data/stubs/3.2/zipfile.pyi diff --git a/stubs/3.2/zlib.pyi b/mypy/data/stubs/3.2/zlib.pyi similarity index 100% rename from stubs/3.2/zlib.pyi rename to mypy/data/stubs/3.2/zlib.pyi diff --git a/stubs/3.3/do-not-remove b/mypy/data/stubs/3.3/do-not-remove similarity index 100% rename from stubs/3.3/do-not-remove rename to mypy/data/stubs/3.3/do-not-remove diff --git a/stubs/3.3/ipaddress.pyi b/mypy/data/stubs/3.3/ipaddress.pyi similarity index 100% rename from stubs/3.3/ipaddress.pyi rename to mypy/data/stubs/3.3/ipaddress.pyi diff --git a/stubs/3.4/asyncio/__init__.pyi b/mypy/data/stubs/3.4/asyncio/__init__.pyi similarity index 100% rename from stubs/3.4/asyncio/__init__.pyi rename to mypy/data/stubs/3.4/asyncio/__init__.pyi diff --git a/stubs/3.4/asyncio/events.pyi b/mypy/data/stubs/3.4/asyncio/events.pyi similarity index 100% rename from stubs/3.4/asyncio/events.pyi rename to mypy/data/stubs/3.4/asyncio/events.pyi diff --git a/stubs/3.4/asyncio/futures.pyi b/mypy/data/stubs/3.4/asyncio/futures.pyi similarity index 100% rename from stubs/3.4/asyncio/futures.pyi rename to mypy/data/stubs/3.4/asyncio/futures.pyi diff --git a/stubs/3.4/asyncio/queues.pyi b/mypy/data/stubs/3.4/asyncio/queues.pyi similarity index 100% rename from stubs/3.4/asyncio/queues.pyi rename to mypy/data/stubs/3.4/asyncio/queues.pyi diff --git a/stubs/3.4/asyncio/tasks.pyi b/mypy/data/stubs/3.4/asyncio/tasks.pyi similarity index 100% rename from stubs/3.4/asyncio/tasks.pyi rename to mypy/data/stubs/3.4/asyncio/tasks.pyi diff --git a/stubs/3.4/enum.pyi b/mypy/data/stubs/3.4/enum.pyi similarity index 100% rename from stubs/3.4/enum.pyi rename to mypy/data/stubs/3.4/enum.pyi diff --git a/stubs/3.4/pathlib.pyi b/mypy/data/stubs/3.4/pathlib.pyi similarity index 100% rename from stubs/3.4/pathlib.pyi rename to mypy/data/stubs/3.4/pathlib.pyi diff --git a/stubs/third-party-2.7/Crypto/Cipher/AES.pyi b/mypy/data/stubs/third-party-2.7/Crypto/Cipher/AES.pyi similarity index 100% rename from stubs/third-party-2.7/Crypto/Cipher/AES.pyi rename to mypy/data/stubs/third-party-2.7/Crypto/Cipher/AES.pyi diff --git a/stubs/third-party-2.7/Crypto/Cipher/__init__.pyi b/mypy/data/stubs/third-party-2.7/Crypto/Cipher/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/Crypto/Cipher/__init__.pyi rename to mypy/data/stubs/third-party-2.7/Crypto/Cipher/__init__.pyi diff --git a/stubs/third-party-2.7/Crypto/Random/__init__.pyi b/mypy/data/stubs/third-party-2.7/Crypto/Random/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/Crypto/Random/__init__.pyi rename to mypy/data/stubs/third-party-2.7/Crypto/Random/__init__.pyi diff --git a/stubs/third-party-2.7/Crypto/Random/random.pyi b/mypy/data/stubs/third-party-2.7/Crypto/Random/random.pyi similarity index 100% rename from stubs/third-party-2.7/Crypto/Random/random.pyi rename to mypy/data/stubs/third-party-2.7/Crypto/Random/random.pyi diff --git a/stubs/third-party-2.7/concurrent/__init__.pyi b/mypy/data/stubs/third-party-2.7/Crypto/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/concurrent/__init__.pyi rename to mypy/data/stubs/third-party-2.7/Crypto/__init__.pyi diff --git a/stubs/third-party-2.7/fb303/__init__.pyi b/mypy/data/stubs/third-party-2.7/OpenSSL/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/fb303/__init__.pyi rename to mypy/data/stubs/third-party-2.7/OpenSSL/__init__.pyi diff --git a/stubs/third-party-2.7/OpenSSL/crypto.pyi b/mypy/data/stubs/third-party-2.7/OpenSSL/crypto.pyi similarity index 100% rename from stubs/third-party-2.7/OpenSSL/crypto.pyi rename to mypy/data/stubs/third-party-2.7/OpenSSL/crypto.pyi diff --git a/stubs/third-party-2.7/boto/__init__.pyi b/mypy/data/stubs/third-party-2.7/boto/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/boto/__init__.pyi rename to mypy/data/stubs/third-party-2.7/boto/__init__.pyi diff --git a/stubs/third-party-2.7/boto/connection.pyi b/mypy/data/stubs/third-party-2.7/boto/connection.pyi similarity index 100% rename from stubs/third-party-2.7/boto/connection.pyi rename to mypy/data/stubs/third-party-2.7/boto/connection.pyi diff --git a/stubs/third-party-2.7/boto/ec2/__init__.pyi b/mypy/data/stubs/third-party-2.7/boto/ec2/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/boto/ec2/__init__.pyi rename to mypy/data/stubs/third-party-2.7/boto/ec2/__init__.pyi diff --git a/stubs/third-party-2.7/boto/ec2/elb/__init__.pyi b/mypy/data/stubs/third-party-2.7/boto/ec2/elb/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/boto/ec2/elb/__init__.pyi rename to mypy/data/stubs/third-party-2.7/boto/ec2/elb/__init__.pyi diff --git a/stubs/third-party-2.7/google/__init__.pyi b/mypy/data/stubs/third-party-2.7/concurrent/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/google/__init__.pyi rename to mypy/data/stubs/third-party-2.7/concurrent/__init__.pyi diff --git a/stubs/third-party-2.7/concurrent/futures/__init__.pyi b/mypy/data/stubs/third-party-2.7/concurrent/futures/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/concurrent/futures/__init__.pyi rename to mypy/data/stubs/third-party-2.7/concurrent/futures/__init__.pyi diff --git a/stubs/third-party-2.7/croniter.pyi b/mypy/data/stubs/third-party-2.7/croniter.pyi similarity index 100% rename from stubs/third-party-2.7/croniter.pyi rename to mypy/data/stubs/third-party-2.7/croniter.pyi diff --git a/stubs/third-party-2.7/fb303/FacebookService.pyi b/mypy/data/stubs/third-party-2.7/fb303/FacebookService.pyi similarity index 100% rename from stubs/third-party-2.7/fb303/FacebookService.pyi rename to mypy/data/stubs/third-party-2.7/fb303/FacebookService.pyi diff --git a/stubs/third-party-2.7/google/protobuf/__init__.pyi b/mypy/data/stubs/third-party-2.7/fb303/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/__init__.pyi rename to mypy/data/stubs/third-party-2.7/fb303/__init__.pyi diff --git a/stubs/third-party-2.7/gflags.pyi b/mypy/data/stubs/third-party-2.7/gflags.pyi similarity index 100% rename from stubs/third-party-2.7/gflags.pyi rename to mypy/data/stubs/third-party-2.7/gflags.pyi diff --git a/stubs/third-party-2.7/google/protobuf/internal/__init__.pyi b/mypy/data/stubs/third-party-2.7/google/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/internal/__init__.pyi rename to mypy/data/stubs/third-party-2.7/google/__init__.pyi diff --git a/stubs/third-party-2.7/scribe/__init__.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/scribe/__init__.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/__init__.pyi diff --git a/stubs/third-party-2.7/google/protobuf/descriptor.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/descriptor.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/descriptor.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/descriptor.pyi diff --git a/stubs/third-party-2.7/google/protobuf/descriptor_pb2.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/descriptor_pb2.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/descriptor_pb2.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/descriptor_pb2.pyi diff --git a/stubs/third-party-2.7/thrift/__init__.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/internal/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/__init__.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/internal/__init__.pyi diff --git a/stubs/third-party-2.7/google/protobuf/internal/decoder.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/internal/decoder.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/internal/decoder.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/internal/decoder.pyi diff --git a/stubs/third-party-2.7/google/protobuf/internal/encoder.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/internal/encoder.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/internal/encoder.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/internal/encoder.pyi diff --git a/stubs/third-party-2.7/google/protobuf/internal/enum_type_wrapper.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/internal/enum_type_wrapper.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/internal/enum_type_wrapper.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/internal/enum_type_wrapper.pyi diff --git a/stubs/third-party-2.7/google/protobuf/internal/wire_format.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/internal/wire_format.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/internal/wire_format.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/internal/wire_format.pyi diff --git a/stubs/third-party-2.7/google/protobuf/message.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/message.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/message.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/message.pyi diff --git a/stubs/third-party-2.7/google/protobuf/reflection.pyi b/mypy/data/stubs/third-party-2.7/google/protobuf/reflection.pyi similarity index 100% rename from stubs/third-party-2.7/google/protobuf/reflection.pyi rename to mypy/data/stubs/third-party-2.7/google/protobuf/reflection.pyi diff --git a/stubs/third-party-2.7/kazoo/__init__.pyi b/mypy/data/stubs/third-party-2.7/kazoo/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/kazoo/__init__.pyi rename to mypy/data/stubs/third-party-2.7/kazoo/__init__.pyi diff --git a/stubs/third-party-2.7/kazoo/client.pyi b/mypy/data/stubs/third-party-2.7/kazoo/client.pyi similarity index 100% rename from stubs/third-party-2.7/kazoo/client.pyi rename to mypy/data/stubs/third-party-2.7/kazoo/client.pyi diff --git a/stubs/third-party-2.7/kazoo/exceptions.pyi b/mypy/data/stubs/third-party-2.7/kazoo/exceptions.pyi similarity index 100% rename from stubs/third-party-2.7/kazoo/exceptions.pyi rename to mypy/data/stubs/third-party-2.7/kazoo/exceptions.pyi diff --git a/stubs/third-party-2.7/kazoo/recipe/__init__.pyi b/mypy/data/stubs/third-party-2.7/kazoo/recipe/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/kazoo/recipe/__init__.pyi rename to mypy/data/stubs/third-party-2.7/kazoo/recipe/__init__.pyi diff --git a/stubs/third-party-2.7/kazoo/recipe/watchers.pyi b/mypy/data/stubs/third-party-2.7/kazoo/recipe/watchers.pyi similarity index 100% rename from stubs/third-party-2.7/kazoo/recipe/watchers.pyi rename to mypy/data/stubs/third-party-2.7/kazoo/recipe/watchers.pyi diff --git a/stubs/third-party-2.7/pycurl.pyi b/mypy/data/stubs/third-party-2.7/pycurl.pyi similarity index 100% rename from stubs/third-party-2.7/pycurl.pyi rename to mypy/data/stubs/third-party-2.7/pycurl.pyi diff --git a/stubs/third-party-2.7/redis/__init__.pyi b/mypy/data/stubs/third-party-2.7/redis/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/redis/__init__.pyi rename to mypy/data/stubs/third-party-2.7/redis/__init__.pyi diff --git a/stubs/third-party-2.7/redis/client.pyi b/mypy/data/stubs/third-party-2.7/redis/client.pyi similarity index 100% rename from stubs/third-party-2.7/redis/client.pyi rename to mypy/data/stubs/third-party-2.7/redis/client.pyi diff --git a/stubs/third-party-2.7/redis/connection.pyi b/mypy/data/stubs/third-party-2.7/redis/connection.pyi similarity index 100% rename from stubs/third-party-2.7/redis/connection.pyi rename to mypy/data/stubs/third-party-2.7/redis/connection.pyi diff --git a/stubs/third-party-2.7/redis/exceptions.pyi b/mypy/data/stubs/third-party-2.7/redis/exceptions.pyi similarity index 100% rename from stubs/third-party-2.7/redis/exceptions.pyi rename to mypy/data/stubs/third-party-2.7/redis/exceptions.pyi diff --git a/stubs/third-party-2.7/redis/utils.pyi b/mypy/data/stubs/third-party-2.7/redis/utils.pyi similarity index 100% rename from stubs/third-party-2.7/redis/utils.pyi rename to mypy/data/stubs/third-party-2.7/redis/utils.pyi diff --git a/stubs/third-party-2.7/requests/__init__.pyi b/mypy/data/stubs/third-party-2.7/requests/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/requests/__init__.pyi rename to mypy/data/stubs/third-party-2.7/requests/__init__.pyi diff --git a/stubs/third-party-2.7/requests/adapters.pyi b/mypy/data/stubs/third-party-2.7/requests/adapters.pyi similarity index 100% rename from stubs/third-party-2.7/requests/adapters.pyi rename to mypy/data/stubs/third-party-2.7/requests/adapters.pyi diff --git a/stubs/third-party-2.7/requests/api.pyi b/mypy/data/stubs/third-party-2.7/requests/api.pyi similarity index 100% rename from stubs/third-party-2.7/requests/api.pyi rename to mypy/data/stubs/third-party-2.7/requests/api.pyi diff --git a/stubs/third-party-2.7/requests/auth.pyi b/mypy/data/stubs/third-party-2.7/requests/auth.pyi similarity index 100% rename from stubs/third-party-2.7/requests/auth.pyi rename to mypy/data/stubs/third-party-2.7/requests/auth.pyi diff --git a/stubs/third-party-2.7/requests/compat.pyi b/mypy/data/stubs/third-party-2.7/requests/compat.pyi similarity index 100% rename from stubs/third-party-2.7/requests/compat.pyi rename to mypy/data/stubs/third-party-2.7/requests/compat.pyi diff --git a/stubs/third-party-2.7/requests/cookies.pyi b/mypy/data/stubs/third-party-2.7/requests/cookies.pyi similarity index 100% rename from stubs/third-party-2.7/requests/cookies.pyi rename to mypy/data/stubs/third-party-2.7/requests/cookies.pyi diff --git a/stubs/third-party-2.7/requests/exceptions.pyi b/mypy/data/stubs/third-party-2.7/requests/exceptions.pyi similarity index 100% rename from stubs/third-party-2.7/requests/exceptions.pyi rename to mypy/data/stubs/third-party-2.7/requests/exceptions.pyi diff --git a/stubs/third-party-2.7/requests/hooks.pyi b/mypy/data/stubs/third-party-2.7/requests/hooks.pyi similarity index 100% rename from stubs/third-party-2.7/requests/hooks.pyi rename to mypy/data/stubs/third-party-2.7/requests/hooks.pyi diff --git a/stubs/third-party-2.7/requests/models.pyi b/mypy/data/stubs/third-party-2.7/requests/models.pyi similarity index 100% rename from stubs/third-party-2.7/requests/models.pyi rename to mypy/data/stubs/third-party-2.7/requests/models.pyi diff --git a/stubs/third-party-2.7/requests/packages/__init__.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/__init__.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/__init__.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/__init__.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/__init__.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/__init__.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/_collections.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/_collections.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/_collections.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/_collections.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/connection.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/connection.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/connection.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/connection.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/connectionpool.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/connectionpool.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/connectionpool.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/connectionpool.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/contrib/__init__.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/contrib/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/contrib/__init__.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/contrib/__init__.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/exceptions.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/exceptions.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/exceptions.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/exceptions.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/fields.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/fields.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/fields.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/fields.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/filepost.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/filepost.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/filepost.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/filepost.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/packages/__init__.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/packages/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/packages/__init__.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/packages/__init__.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/poolmanager.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/poolmanager.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/poolmanager.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/poolmanager.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/request.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/request.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/request.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/request.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/response.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/response.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/response.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/response.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/__init__.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/__init__.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/__init__.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/connection.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/connection.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/connection.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/connection.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/request.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/request.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/request.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/request.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/response.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/response.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/response.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/response.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/retry.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/retry.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/retry.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/retry.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/timeout.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/timeout.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/timeout.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/timeout.pyi diff --git a/stubs/third-party-2.7/requests/packages/urllib3/util/url.pyi b/mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/url.pyi similarity index 100% rename from stubs/third-party-2.7/requests/packages/urllib3/util/url.pyi rename to mypy/data/stubs/third-party-2.7/requests/packages/urllib3/util/url.pyi diff --git a/stubs/third-party-2.7/requests/sessions.pyi b/mypy/data/stubs/third-party-2.7/requests/sessions.pyi similarity index 100% rename from stubs/third-party-2.7/requests/sessions.pyi rename to mypy/data/stubs/third-party-2.7/requests/sessions.pyi diff --git a/stubs/third-party-2.7/requests/status_codes.pyi b/mypy/data/stubs/third-party-2.7/requests/status_codes.pyi similarity index 100% rename from stubs/third-party-2.7/requests/status_codes.pyi rename to mypy/data/stubs/third-party-2.7/requests/status_codes.pyi diff --git a/stubs/third-party-2.7/requests/structures.pyi b/mypy/data/stubs/third-party-2.7/requests/structures.pyi similarity index 100% rename from stubs/third-party-2.7/requests/structures.pyi rename to mypy/data/stubs/third-party-2.7/requests/structures.pyi diff --git a/stubs/third-party-2.7/requests/utils.pyi b/mypy/data/stubs/third-party-2.7/requests/utils.pyi similarity index 100% rename from stubs/third-party-2.7/requests/utils.pyi rename to mypy/data/stubs/third-party-2.7/requests/utils.pyi diff --git a/stubs/third-party-2.7/routes/__init__.pyi b/mypy/data/stubs/third-party-2.7/routes/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/routes/__init__.pyi rename to mypy/data/stubs/third-party-2.7/routes/__init__.pyi diff --git a/stubs/third-party-2.7/routes/mapper.pyi b/mypy/data/stubs/third-party-2.7/routes/mapper.pyi similarity index 100% rename from stubs/third-party-2.7/routes/mapper.pyi rename to mypy/data/stubs/third-party-2.7/routes/mapper.pyi diff --git a/stubs/third-party-2.7/routes/util.pyi b/mypy/data/stubs/third-party-2.7/routes/util.pyi similarity index 100% rename from stubs/third-party-2.7/routes/util.pyi rename to mypy/data/stubs/third-party-2.7/routes/util.pyi diff --git a/stubs/third-party-2.7/tornado/__init__.pyi b/mypy/data/stubs/third-party-2.7/scribe/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/__init__.pyi rename to mypy/data/stubs/third-party-2.7/scribe/__init__.pyi diff --git a/stubs/third-party-2.7/scribe/scribe.pyi b/mypy/data/stubs/third-party-2.7/scribe/scribe.pyi similarity index 100% rename from stubs/third-party-2.7/scribe/scribe.pyi rename to mypy/data/stubs/third-party-2.7/scribe/scribe.pyi diff --git a/stubs/third-party-2.7/scribe/ttypes.pyi b/mypy/data/stubs/third-party-2.7/scribe/ttypes.pyi similarity index 100% rename from stubs/third-party-2.7/scribe/ttypes.pyi rename to mypy/data/stubs/third-party-2.7/scribe/ttypes.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/databases/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/databases/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/databases/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/databases/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/databases/mysql.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/databases/mysql.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/databases/mysql.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/databases/mysql.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/dialects/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/dialects/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/dialects/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/dialects/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/dialects/mysql/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/dialects/mysql/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/dialects/mysql/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/dialects/mysql/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/dialects/mysql/base.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/dialects/mysql/base.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/dialects/mysql/base.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/dialects/mysql/base.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/engine/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/engine/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/engine/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/engine/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/engine/strategies.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/engine/strategies.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/engine/strategies.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/engine/strategies.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/engine/url.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/engine/url.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/engine/url.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/engine/url.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/exc.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/exc.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/exc.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/exc.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/inspection.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/inspection.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/inspection.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/inspection.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/orm/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/orm/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/orm/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/orm/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/orm/session.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/orm/session.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/orm/session.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/orm/session.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/pool.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/pool.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/pool.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/pool.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/schema.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/schema.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/schema.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/schema.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/sql/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/sql/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/sql/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/sql/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/sql/expression.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/sql/expression.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/sql/expression.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/sql/expression.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/sql/visitors.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/sql/visitors.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/sql/visitors.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/sql/visitors.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/types.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/types.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/types.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/types.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/util/__init__.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/util/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/util/__init__.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/util/__init__.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/util/_collections.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/util/_collections.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/util/_collections.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/util/_collections.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/util/compat.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/util/compat.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/util/compat.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/util/compat.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/util/deprecations.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/util/deprecations.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/util/deprecations.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/util/deprecations.pyi diff --git a/stubs/third-party-2.7/sqlalchemy/util/langhelpers.pyi b/mypy/data/stubs/third-party-2.7/sqlalchemy/util/langhelpers.pyi similarity index 100% rename from stubs/third-party-2.7/sqlalchemy/util/langhelpers.pyi rename to mypy/data/stubs/third-party-2.7/sqlalchemy/util/langhelpers.pyi diff --git a/stubs/third-party-2.7/thrift/Thrift.pyi b/mypy/data/stubs/third-party-2.7/thrift/Thrift.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/Thrift.pyi rename to mypy/data/stubs/third-party-2.7/thrift/Thrift.pyi diff --git a/stubs/third-party-3.2/docutils/parsers/rst/__init__.pyi b/mypy/data/stubs/third-party-2.7/thrift/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/parsers/rst/__init__.pyi rename to mypy/data/stubs/third-party-2.7/thrift/__init__.pyi diff --git a/stubs/third-party-2.7/thrift/protocol/TBinaryProtocol.pyi b/mypy/data/stubs/third-party-2.7/thrift/protocol/TBinaryProtocol.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/protocol/TBinaryProtocol.pyi rename to mypy/data/stubs/third-party-2.7/thrift/protocol/TBinaryProtocol.pyi diff --git a/stubs/third-party-2.7/thrift/protocol/TProtocol.pyi b/mypy/data/stubs/third-party-2.7/thrift/protocol/TProtocol.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/protocol/TProtocol.pyi rename to mypy/data/stubs/third-party-2.7/thrift/protocol/TProtocol.pyi diff --git a/stubs/third-party-2.7/thrift/protocol/__init__.pyi b/mypy/data/stubs/third-party-2.7/thrift/protocol/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/protocol/__init__.pyi rename to mypy/data/stubs/third-party-2.7/thrift/protocol/__init__.pyi diff --git a/stubs/third-party-2.7/thrift/transport/TSocket.pyi b/mypy/data/stubs/third-party-2.7/thrift/transport/TSocket.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/transport/TSocket.pyi rename to mypy/data/stubs/third-party-2.7/thrift/transport/TSocket.pyi diff --git a/stubs/third-party-2.7/thrift/transport/TTransport.pyi b/mypy/data/stubs/third-party-2.7/thrift/transport/TTransport.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/transport/TTransport.pyi rename to mypy/data/stubs/third-party-2.7/thrift/transport/TTransport.pyi diff --git a/stubs/third-party-2.7/thrift/transport/__init__.pyi b/mypy/data/stubs/third-party-2.7/thrift/transport/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/thrift/transport/__init__.pyi rename to mypy/data/stubs/third-party-2.7/thrift/transport/__init__.pyi diff --git a/stubs/third-party-3.2/lxml/__init__.pyi b/mypy/data/stubs/third-party-2.7/tornado/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/lxml/__init__.pyi rename to mypy/data/stubs/third-party-2.7/tornado/__init__.pyi diff --git a/stubs/third-party-2.7/tornado/concurrent.pyi b/mypy/data/stubs/third-party-2.7/tornado/concurrent.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/concurrent.pyi rename to mypy/data/stubs/third-party-2.7/tornado/concurrent.pyi diff --git a/stubs/third-party-2.7/tornado/gen.pyi b/mypy/data/stubs/third-party-2.7/tornado/gen.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/gen.pyi rename to mypy/data/stubs/third-party-2.7/tornado/gen.pyi diff --git a/stubs/third-party-2.7/tornado/httpclient.pyi b/mypy/data/stubs/third-party-2.7/tornado/httpclient.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/httpclient.pyi rename to mypy/data/stubs/third-party-2.7/tornado/httpclient.pyi diff --git a/stubs/third-party-2.7/tornado/httpserver.pyi b/mypy/data/stubs/third-party-2.7/tornado/httpserver.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/httpserver.pyi rename to mypy/data/stubs/third-party-2.7/tornado/httpserver.pyi diff --git a/stubs/third-party-2.7/tornado/httputil.pyi b/mypy/data/stubs/third-party-2.7/tornado/httputil.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/httputil.pyi rename to mypy/data/stubs/third-party-2.7/tornado/httputil.pyi diff --git a/stubs/third-party-2.7/tornado/ioloop.pyi b/mypy/data/stubs/third-party-2.7/tornado/ioloop.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/ioloop.pyi rename to mypy/data/stubs/third-party-2.7/tornado/ioloop.pyi diff --git a/stubs/third-party-2.7/tornado/netutil.pyi b/mypy/data/stubs/third-party-2.7/tornado/netutil.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/netutil.pyi rename to mypy/data/stubs/third-party-2.7/tornado/netutil.pyi diff --git a/stubs/third-party-2.7/tornado/tcpserver.pyi b/mypy/data/stubs/third-party-2.7/tornado/tcpserver.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/tcpserver.pyi rename to mypy/data/stubs/third-party-2.7/tornado/tcpserver.pyi diff --git a/stubs/third-party-2.7/tornado/util.pyi b/mypy/data/stubs/third-party-2.7/tornado/util.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/util.pyi rename to mypy/data/stubs/third-party-2.7/tornado/util.pyi diff --git a/stubs/third-party-2.7/tornado/web.pyi b/mypy/data/stubs/third-party-2.7/tornado/web.pyi similarity index 100% rename from stubs/third-party-2.7/tornado/web.pyi rename to mypy/data/stubs/third-party-2.7/tornado/web.pyi diff --git a/stubs/third-party-2.7/yaml/__init__.pyi b/mypy/data/stubs/third-party-2.7/yaml/__init__.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/__init__.pyi rename to mypy/data/stubs/third-party-2.7/yaml/__init__.pyi diff --git a/stubs/third-party-2.7/yaml/composer.pyi b/mypy/data/stubs/third-party-2.7/yaml/composer.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/composer.pyi rename to mypy/data/stubs/third-party-2.7/yaml/composer.pyi diff --git a/stubs/third-party-2.7/yaml/constructor.pyi b/mypy/data/stubs/third-party-2.7/yaml/constructor.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/constructor.pyi rename to mypy/data/stubs/third-party-2.7/yaml/constructor.pyi diff --git a/stubs/third-party-2.7/yaml/dumper.pyi b/mypy/data/stubs/third-party-2.7/yaml/dumper.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/dumper.pyi rename to mypy/data/stubs/third-party-2.7/yaml/dumper.pyi diff --git a/stubs/third-party-2.7/yaml/emitter.pyi b/mypy/data/stubs/third-party-2.7/yaml/emitter.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/emitter.pyi rename to mypy/data/stubs/third-party-2.7/yaml/emitter.pyi diff --git a/stubs/third-party-2.7/yaml/error.pyi b/mypy/data/stubs/third-party-2.7/yaml/error.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/error.pyi rename to mypy/data/stubs/third-party-2.7/yaml/error.pyi diff --git a/stubs/third-party-2.7/yaml/events.pyi b/mypy/data/stubs/third-party-2.7/yaml/events.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/events.pyi rename to mypy/data/stubs/third-party-2.7/yaml/events.pyi diff --git a/stubs/third-party-2.7/yaml/loader.pyi b/mypy/data/stubs/third-party-2.7/yaml/loader.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/loader.pyi rename to mypy/data/stubs/third-party-2.7/yaml/loader.pyi diff --git a/stubs/third-party-2.7/yaml/nodes.pyi b/mypy/data/stubs/third-party-2.7/yaml/nodes.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/nodes.pyi rename to mypy/data/stubs/third-party-2.7/yaml/nodes.pyi diff --git a/stubs/third-party-2.7/yaml/parser.pyi b/mypy/data/stubs/third-party-2.7/yaml/parser.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/parser.pyi rename to mypy/data/stubs/third-party-2.7/yaml/parser.pyi diff --git a/stubs/third-party-2.7/yaml/reader.pyi b/mypy/data/stubs/third-party-2.7/yaml/reader.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/reader.pyi rename to mypy/data/stubs/third-party-2.7/yaml/reader.pyi diff --git a/stubs/third-party-2.7/yaml/representer.pyi b/mypy/data/stubs/third-party-2.7/yaml/representer.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/representer.pyi rename to mypy/data/stubs/third-party-2.7/yaml/representer.pyi diff --git a/stubs/third-party-2.7/yaml/resolver.pyi b/mypy/data/stubs/third-party-2.7/yaml/resolver.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/resolver.pyi rename to mypy/data/stubs/third-party-2.7/yaml/resolver.pyi diff --git a/stubs/third-party-2.7/yaml/scanner.pyi b/mypy/data/stubs/third-party-2.7/yaml/scanner.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/scanner.pyi rename to mypy/data/stubs/third-party-2.7/yaml/scanner.pyi diff --git a/stubs/third-party-2.7/yaml/serializer.pyi b/mypy/data/stubs/third-party-2.7/yaml/serializer.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/serializer.pyi rename to mypy/data/stubs/third-party-2.7/yaml/serializer.pyi diff --git a/stubs/third-party-2.7/yaml/tokens.pyi b/mypy/data/stubs/third-party-2.7/yaml/tokens.pyi similarity index 100% rename from stubs/third-party-2.7/yaml/tokens.pyi rename to mypy/data/stubs/third-party-2.7/yaml/tokens.pyi diff --git a/stubs/third-party-3.2/docutils/__init__.pyi b/mypy/data/stubs/third-party-3.2/docutils/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/__init__.pyi rename to mypy/data/stubs/third-party-3.2/docutils/__init__.pyi diff --git a/stubs/third-party-3.2/docutils/examples.pyi b/mypy/data/stubs/third-party-3.2/docutils/examples.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/examples.pyi rename to mypy/data/stubs/third-party-3.2/docutils/examples.pyi diff --git a/stubs/third-party-3.2/docutils/nodes.pyi b/mypy/data/stubs/third-party-3.2/docutils/nodes.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/nodes.pyi rename to mypy/data/stubs/third-party-3.2/docutils/nodes.pyi diff --git a/stubs/third-party-3.2/docutils/parsers/__init__.pyi b/mypy/data/stubs/third-party-3.2/docutils/parsers/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/parsers/__init__.pyi rename to mypy/data/stubs/third-party-3.2/docutils/parsers/__init__.pyi diff --git a/lib-python/3.2/incomplete/urllib/__init__.py b/mypy/data/stubs/third-party-3.2/docutils/parsers/rst/__init__.pyi similarity index 100% rename from lib-python/3.2/incomplete/urllib/__init__.py rename to mypy/data/stubs/third-party-3.2/docutils/parsers/rst/__init__.pyi diff --git a/stubs/third-party-3.2/docutils/parsers/rst/nodes.pyi b/mypy/data/stubs/third-party-3.2/docutils/parsers/rst/nodes.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/parsers/rst/nodes.pyi rename to mypy/data/stubs/third-party-3.2/docutils/parsers/rst/nodes.pyi diff --git a/stubs/third-party-3.2/docutils/parsers/rst/roles.pyi b/mypy/data/stubs/third-party-3.2/docutils/parsers/rst/roles.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/parsers/rst/roles.pyi rename to mypy/data/stubs/third-party-3.2/docutils/parsers/rst/roles.pyi diff --git a/stubs/third-party-3.2/docutils/parsers/rst/states.pyi b/mypy/data/stubs/third-party-3.2/docutils/parsers/rst/states.pyi similarity index 100% rename from stubs/third-party-3.2/docutils/parsers/rst/states.pyi rename to mypy/data/stubs/third-party-3.2/docutils/parsers/rst/states.pyi diff --git a/lib-python/3.2/test/__init__.py b/mypy/data/stubs/third-party-3.2/lxml/__init__.pyi similarity index 100% rename from lib-python/3.2/test/__init__.py rename to mypy/data/stubs/third-party-3.2/lxml/__init__.pyi diff --git a/stubs/third-party-3.2/lxml/etree.pyi b/mypy/data/stubs/third-party-3.2/lxml/etree.pyi similarity index 100% rename from stubs/third-party-3.2/lxml/etree.pyi rename to mypy/data/stubs/third-party-3.2/lxml/etree.pyi diff --git a/stubs/third-party-3.2/requests/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/__init__.pyi diff --git a/stubs/third-party-3.2/requests/adapters.pyi b/mypy/data/stubs/third-party-3.2/requests/adapters.pyi similarity index 100% rename from stubs/third-party-3.2/requests/adapters.pyi rename to mypy/data/stubs/third-party-3.2/requests/adapters.pyi diff --git a/stubs/third-party-3.2/requests/api.pyi b/mypy/data/stubs/third-party-3.2/requests/api.pyi similarity index 100% rename from stubs/third-party-3.2/requests/api.pyi rename to mypy/data/stubs/third-party-3.2/requests/api.pyi diff --git a/stubs/third-party-3.2/requests/auth.pyi b/mypy/data/stubs/third-party-3.2/requests/auth.pyi similarity index 100% rename from stubs/third-party-3.2/requests/auth.pyi rename to mypy/data/stubs/third-party-3.2/requests/auth.pyi diff --git a/stubs/third-party-3.2/requests/compat.pyi b/mypy/data/stubs/third-party-3.2/requests/compat.pyi similarity index 100% rename from stubs/third-party-3.2/requests/compat.pyi rename to mypy/data/stubs/third-party-3.2/requests/compat.pyi diff --git a/stubs/third-party-3.2/requests/cookies.pyi b/mypy/data/stubs/third-party-3.2/requests/cookies.pyi similarity index 100% rename from stubs/third-party-3.2/requests/cookies.pyi rename to mypy/data/stubs/third-party-3.2/requests/cookies.pyi diff --git a/stubs/third-party-3.2/requests/exceptions.pyi b/mypy/data/stubs/third-party-3.2/requests/exceptions.pyi similarity index 100% rename from stubs/third-party-3.2/requests/exceptions.pyi rename to mypy/data/stubs/third-party-3.2/requests/exceptions.pyi diff --git a/stubs/third-party-3.2/requests/hooks.pyi b/mypy/data/stubs/third-party-3.2/requests/hooks.pyi similarity index 100% rename from stubs/third-party-3.2/requests/hooks.pyi rename to mypy/data/stubs/third-party-3.2/requests/hooks.pyi diff --git a/stubs/third-party-3.2/requests/models.pyi b/mypy/data/stubs/third-party-3.2/requests/models.pyi similarity index 100% rename from stubs/third-party-3.2/requests/models.pyi rename to mypy/data/stubs/third-party-3.2/requests/models.pyi diff --git a/stubs/third-party-3.2/requests/packages/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/__init__.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/__init__.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/_collections.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/_collections.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/_collections.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/_collections.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/connection.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/connection.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/connection.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/connection.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/connectionpool.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/connectionpool.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/connectionpool.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/connectionpool.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/contrib/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/contrib/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/contrib/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/contrib/__init__.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/exceptions.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/exceptions.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/exceptions.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/exceptions.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/fields.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/fields.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/fields.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/fields.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/filepost.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/filepost.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/filepost.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/filepost.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/packages/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/packages/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/packages/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/packages/__init__.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/poolmanager.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/poolmanager.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/poolmanager.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/poolmanager.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/request.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/request.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/request.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/request.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/response.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/response.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/response.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/response.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/__init__.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/__init__.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/__init__.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/__init__.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/connection.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/connection.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/connection.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/connection.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/request.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/request.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/request.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/request.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/response.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/response.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/response.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/response.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/retry.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/retry.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/retry.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/retry.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/ssl_.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/ssl_.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/ssl_.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/ssl_.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/timeout.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/timeout.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/timeout.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/timeout.pyi diff --git a/stubs/third-party-3.2/requests/packages/urllib3/util/url.pyi b/mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/url.pyi similarity index 100% rename from stubs/third-party-3.2/requests/packages/urllib3/util/url.pyi rename to mypy/data/stubs/third-party-3.2/requests/packages/urllib3/util/url.pyi diff --git a/stubs/third-party-3.2/requests/sessions.pyi b/mypy/data/stubs/third-party-3.2/requests/sessions.pyi similarity index 100% rename from stubs/third-party-3.2/requests/sessions.pyi rename to mypy/data/stubs/third-party-3.2/requests/sessions.pyi diff --git a/stubs/third-party-3.2/requests/status_codes.pyi b/mypy/data/stubs/third-party-3.2/requests/status_codes.pyi similarity index 100% rename from stubs/third-party-3.2/requests/status_codes.pyi rename to mypy/data/stubs/third-party-3.2/requests/status_codes.pyi diff --git a/stubs/third-party-3.2/requests/structures.pyi b/mypy/data/stubs/third-party-3.2/requests/structures.pyi similarity index 100% rename from stubs/third-party-3.2/requests/structures.pyi rename to mypy/data/stubs/third-party-3.2/requests/structures.pyi diff --git a/stubs/third-party-3.2/requests/utils.pyi b/mypy/data/stubs/third-party-3.2/requests/utils.pyi similarity index 100% rename from stubs/third-party-3.2/requests/utils.pyi rename to mypy/data/stubs/third-party-3.2/requests/utils.pyi diff --git a/xml/mypy-html.css b/mypy/data/xml/mypy-html.css similarity index 100% rename from xml/mypy-html.css rename to mypy/data/xml/mypy-html.css diff --git a/xml/mypy-html.xslt b/mypy/data/xml/mypy-html.xslt similarity index 100% rename from xml/mypy-html.xslt rename to mypy/data/xml/mypy-html.xslt diff --git a/xml/mypy-txt.xslt b/mypy/data/xml/mypy-txt.xslt similarity index 100% rename from xml/mypy-txt.xslt rename to mypy/data/xml/mypy-txt.xslt diff --git a/xml/mypy.xsd b/mypy/data/xml/mypy.xsd similarity index 100% rename from xml/mypy.xsd rename to mypy/data/xml/mypy.xsd diff --git a/mypy/defaults.py b/mypy/defaults.py deleted file mode 100644 index 5a0875f525e2..000000000000 --- a/mypy/defaults.py +++ /dev/null @@ -1,2 +0,0 @@ -PYTHON2_VERSION = (2, 7) -PYTHON3_VERSION = (3, 5) diff --git a/mypy/lex.py b/mypy/lex.py index 56f8c79afbb8..12ed1bbbc522 100644 --- a/mypy/lex.py +++ b/mypy/lex.py @@ -8,8 +8,8 @@ import re +from mypy.syntax.dialect import Dialect, default_dialect from mypy.util import short_type -from mypy import defaults from typing import List, Callable, Dict, Any, Match, Pattern, Set, Union, Tuple @@ -159,14 +159,13 @@ def __str__(self): def lex(string: Union[str, bytes], first_line: int = 1, - pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION, - is_stub_file: bool = False) -> Tuple[List[Token], Set[int]]: + dialect: Dialect = default_dialect()) -> Tuple[List[Token], Set[int]]: """Analyze string, and return an array of token objects and the lines to ignore. The last token is always Eof. The intention is to ignore any semantic and type check errors on the ignored lines. """ - l = Lexer(pyversion, is_stub_file=is_stub_file) + l = Lexer(dialect) l.lex(string, first_line) return l.tok, l.ignored_lines @@ -293,19 +292,17 @@ class Lexer: # newlines within parentheses/brackets. open_brackets = None # type: List[str] - pyversion = defaults.PYTHON3_VERSION + dialect = None # type: Dialect # Ignore errors on these lines (defined using '# type: ignore'). ignored_lines = None # type: Set[int] - def __init__(self, pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION, - is_stub_file: bool = False) -> None: + def __init__(self, dialect: Dialect = default_dialect()) -> None: self.map = [self.unknown_character] * 256 self.tok = [] self.indents = [0] self.open_brackets = [] - self.pyversion = pyversion - self.is_stub_file = is_stub_file + self.dialect = dialect self.ignored_lines = set() # Fill in the map from valid character codes to relevant lexer methods. for seq, method in [('ABCDEFGHIJKLMNOPQRSTUVWXYZ', self.lex_name), @@ -325,12 +322,12 @@ def __init__(self, pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION, ('-+*/<>%&|^~=!,@', self.lex_misc)]: for c in seq: self.map[ord(c)] = method - if pyversion[0] == 2: + if dialect.major == 2: self.keywords = keywords_common | keywords2 # Decimal/hex/octal/binary literal or integer complex literal self.number_exp1 = re.compile('(0[xXoObB][0-9a-fA-F]+|[0-9]+)[lL]?') - if pyversion[0] == 3: + if dialect.major == 3: self.keywords = keywords_common | keywords3 self.number_exp1 = re.compile('0[xXoObB][0-9a-fA-F]+|[0-9]+') @@ -397,7 +394,7 @@ def find_encoding(self, text: bytes) -> Tuple[str, int]: line = 2 if result.group(1) else 1 return result.group(3).decode('ascii'), line else: - default_encoding = 'utf8' if self.pyversion[0] >= 3 else 'ascii' + default_encoding = 'utf8' if self.dialect.major >= 3 else 'ascii' return default_encoding, -1 def report_unicode_decode_error(self, exc: UnicodeDecodeError, text: bytes) -> None: @@ -487,7 +484,7 @@ def lex_number(self) -> None: self.add_token(LexError(' ' * maxlen, NUMERIC_LITERAL_ERROR)) elif len(s1) == maxlen: # Integer literal. - if self.pyversion[0] >= 3 and self.octal_int.match(s1): + if self.dialect.major >= 3 and self.octal_int.match(s1): # Python 2 style octal literal such as 0377 not supported in Python 3. self.add_token(LexError(s1, NUMERIC_LITERAL_ERROR)) else: diff --git a/mypy/main.py b/mypy/main.py index feaa2fcc8f4a..9d10682dd07a 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -11,7 +11,7 @@ from typing import Dict, List, Tuple from mypy import build -from mypy import defaults +from mypy.syntax.dialect import Implementation, default_implementation from mypy.errors import CompileError from mypy.version import __version__ @@ -22,18 +22,17 @@ def __init__(self) -> None: # Set default options. self.target = build.TYPE_CHECK self.build_flags = [] # type: List[str] - self.pyversion = defaults.PYTHON3_VERSION + self.implementation = None # type: Implementation self.custom_typing_module = None # type: str self.report_dirs = {} # type: Dict[str, str] self.python_path = False def main() -> None: - bin_dir = find_bin_directory() path, module, program_text, options = process_options(sys.argv[1:]) try: if options.target == build.TYPE_CHECK: - type_check_only(path, module, program_text, bin_dir, options) + type_check_only(path, module, program_text, options) else: raise RuntimeError('unsupported target %d' % options.target) except CompileError as e: @@ -42,21 +41,6 @@ def main() -> None: sys.exit(1) -def find_bin_directory() -> str: - """Find the directory that contains this script. - - This is used by build to find stubs and other data files. - """ - script = __file__ - # Follow up to 5 symbolic links (cap to avoid cycles). - for i in range(5): - if os.path.islink(script): - script = readlinkabs(script) - else: - break - return os.path.dirname(script) - - def readlinkabs(link: str) -> str: """Return an absolute path to symbolic link destination.""" # Adapted from code by Greg Smith. @@ -68,14 +52,13 @@ def readlinkabs(link: str) -> str: def type_check_only(path: str, module: str, program_text: str, - bin_dir: str, options: Options) -> None: + options: Options) -> None: # Type check the program and dependencies and translate to Python. build.build(path, module=module, program_text=program_text, - bin_dir=bin_dir, target=build.TYPE_CHECK, - pyversion=options.pyversion, + implementation=options.implementation, custom_typing_module=options.custom_typing_module, report_dirs=options.report_dirs, flags=options.build_flags, @@ -92,23 +75,21 @@ def process_options(args: List[str]) -> Tuple[str, str, str, Options]: options = Options() help = False ver = False + python_executable = None # type: str + force_py2 = False + while args and args[0].startswith('-'): if args[0] == '--verbose': options.build_flags.append(build.VERBOSE) args = args[1:] elif args[0] == '--py2': # Use Python 2 mode. - options.pyversion = defaults.PYTHON2_VERSION + force_py2 = True args = args[1:] - elif args[0] == '--python-version': - version_components = args[1].split(".")[0:2] - if len(version_components) != 2: - fail("Invalid python version {} (expected format: 'x.y')".format( - repr(args[1]))) - if not all(item.isdigit() for item in version_components): - fail("Found non-digit in python version: {}".format( - args[1])) - options.pyversion = (int(version_components[0]), int(version_components[1])) + elif args[0] == '--python-executable': + if len(args) < 2: + fail('argument required') + python_executable = args[1] args = args[2:] elif args[0] == '-m' and args[1:]: options.build_flags.append(build.MODULE) @@ -154,9 +135,12 @@ def process_options(args: List[str]) -> Tuple[str, str, str, Options]: if args[1:]: usage('Extra argument: {}'.format(args[1])) - if options.python_path and options.pyversion[0] == 2: - usage('Python version 2 (or --py2) specified, ' - 'but --use-python-path will search in sys.path of Python 3') + if python_executable is not None: + options.implementation = Implementation(python_executable) + if force_py2 and options.implementation.base_dialect.major != 2: + usage('given --python-executable is not --py2') + else: + options.implementation = default_implementation(force_py2=force_py2) return args[0], None, None, options @@ -199,9 +183,12 @@ def usage(msg: str = None) -> None: --verbose more verbose messages --use-python-path search for modules in sys.path of running Python --version show the current version information + --python-executable emulate this python interpreter + --py2 deprecated, automatically find a python2 interpreter Environment variables: MYPYPATH additional module search path + MYPY_PYTHON interpreter to emulate """ % ', '.join(REPORTS)) sys.exit(2) diff --git a/mypy/parse.py b/mypy/parse.py index a6ac4184db7d..75b3c50c1d5d 100644 --- a/mypy/parse.py +++ b/mypy/parse.py @@ -28,7 +28,7 @@ StarExpr, YieldFromStmt, YieldFromExpr, NonlocalDecl, DictionaryComprehension, SetComprehension, ComplexExpr, EllipsisExpr, YieldExpr, ExecStmt ) -from mypy import defaults +from mypy.syntax.dialect import Dialect, default_dialect from mypy import nodes from mypy.errors import Errors, CompileError from mypy.types import Void, Type, CallableType, AnyType, UnboundType @@ -68,17 +68,19 @@ def parse(source: Union[str, bytes], fnam: str = None, errors: Errors = None, - pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION, + dialect: Dialect = default_dialect(), custom_typing_module: str = None) -> MypyFile: """Parse a source file, without doing any semantic analysis. Return the parse tree. If errors is not provided, raise ParseError on failure. Otherwise, use the errors object to report parse errors. - The pyversion (major, minor) argument determines the Python syntax variant. + The dialect argument determines the Python syntax variant. """ is_stub_file = bool(fnam) and fnam.endswith('.pyi') - parser = Parser(fnam, errors, pyversion, custom_typing_module, is_stub_file=is_stub_file) + if is_stub_file: + dialect = dialect.add_future('mypy-stub') + parser = Parser(fnam, errors, dialect, custom_typing_module) tree = parser.parse(source) tree.path = fnam tree.is_stub = is_stub_file @@ -109,12 +111,11 @@ class Parser: # Lines to ignore (using # type: ignore). ignored_lines = None # type: Set[int] - def __init__(self, fnam: str, errors: Errors, pyversion: Tuple[int, int], - custom_typing_module: str = None, is_stub_file: bool = False) -> None: + def __init__(self, fnam: str, errors: Errors, dialect: Dialect, + custom_typing_module: str = None) -> None: self.raise_on_error = errors is None - self.pyversion = pyversion + self.dialect = dialect self.custom_typing_module = custom_typing_module - self.is_stub_file = is_stub_file if errors is not None: self.errors = errors else: @@ -125,8 +126,7 @@ def __init__(self, fnam: str, errors: Errors, pyversion: Tuple[int, int], self.errors.set_file('') def parse(self, s: Union[str, bytes]) -> MypyFile: - self.tok, self.ignored_lines = lex.lex(s, pyversion=self.pyversion, - is_stub_file=self.is_stub_file) + self.tok, self.ignored_lines = lex.lex(s, dialect=self.dialect) self.ind = 0 self.imports = [] self.future_options = [] @@ -762,7 +762,7 @@ def parse_statement(self) -> Tuple[Node, bool]: is_simple = False elif ts == 'global': stmt = self.parse_global_decl() - elif ts == 'nonlocal' and self.pyversion[0] >= 3: + elif ts == 'nonlocal' and self.dialect.major >= 3: stmt = self.parse_nonlocal_decl() elif ts == 'assert': stmt = self.parse_assert_stmt() @@ -776,10 +776,10 @@ def parse_statement(self) -> Tuple[Node, bool]: elif ts == '@': stmt = self.parse_decorated_function_or_class() is_simple = False - elif ts == 'print' and (self.pyversion[0] == 2 and + elif ts == 'print' and (self.dialect.major == 2 and 'print_function' not in self.future_options): stmt = self.parse_print_stmt() - elif ts == 'exec' and self.pyversion[0] == 2: + elif ts == 'exec' and self.dialect.major == 2: stmt = self.parse_exec_stmt() else: stmt = self.parse_expression_or_assignment() @@ -1034,7 +1034,7 @@ def parse_try_stmt(self) -> Node: self.expect('as') vars.append(self.parse_name_expr()) else: - if (self.pyversion[0] == 2 and + if (self.dialect.major == 2 and isinstance(types[-1], TupleExpr) and len(cast(TupleExpr, types[-1]).items) == 2 and isinstance(cast(TupleExpr, types[-1]).items[1], NameExpr)): @@ -1167,8 +1167,7 @@ def parse_expression(self, prec: int = 0, star_expr_allowed: bool = False) -> No elif isinstance(current, Keyword) and s == "yield": # The expression yield from and yield to assign expr = self.parse_yield_or_yield_from_expr() - elif isinstance(current, EllipsisToken) and (self.pyversion[0] >= 3 - or self.is_stub_file): + elif isinstance(current, EllipsisToken) and self.dialect.ellipsis: expr = self.parse_ellipsis() else: # Invalid expression. @@ -1419,7 +1418,7 @@ def parse_str_expr(self) -> Node: tok.append(t) value += t.parsed() node = None # type: Node - if self.pyversion[0] == 2 and 'unicode_literals' in self.future_options: + if self.dialect.major == 2 and 'unicode_literals' in self.future_options: node = UnicodeExpr(value) else: node = StrExpr(value) @@ -1432,7 +1431,7 @@ def parse_bytes_literal(self) -> Node: while isinstance(self.current(), BytesLit): t = cast(BytesLit, self.skip()) value += t.parsed() - if self.pyversion[0] >= 3: + if self.dialect.major >= 3: node = BytesExpr(value) # type: Node else: node = StrExpr(value) @@ -1445,7 +1444,7 @@ def parse_unicode_literal(self) -> Node: while isinstance(self.current(), UnicodeLit): t = cast(UnicodeLit, self.skip()) value += t.parsed() - if self.pyversion[0] >= 3: + if self.dialect.major >= 3: # Python 3.3 supports u'...' as an alias of '...'. node = StrExpr(value) # type: Node else: @@ -1835,11 +1834,11 @@ def usage(): sys.exit(2) args = sys.argv[1:] - pyversion = defaults.PYTHON3_VERSION + dialect = default_dialect() quiet = False while args and args[0].startswith('--'): if args[0] == '--py2': - pyversion = defaults.PYTHON2_VERSION + dialect = Dialect('2.7.0') elif args[0] == '--quiet': quiet = True else: @@ -1852,7 +1851,7 @@ def usage(): s = open(fnam, 'rb').read() errors = Errors() try: - tree = parse(s, fnam, pyversion=pyversion) + tree = parse(s, fnam, dialect=dialect) if not quiet: print(tree) except CompileError as e: diff --git a/mypy/sametypes.py b/mypy/sametypes.py index acb4e7c987c2..7ea1a437a5c3 100644 --- a/mypy/sametypes.py +++ b/mypy/sametypes.py @@ -2,7 +2,7 @@ from mypy.types import ( Type, UnboundType, ErrorType, AnyType, NoneTyp, Void, TupleType, UnionType, CallableType, - TypeVarType, Instance, TypeVisitor, ErasedType, TypeList + TypeVarType, Instance, TypeVisitor, ErasedType, TypeList, Overloaded ) @@ -91,3 +91,10 @@ def visit_union_type(self, left: UnionType) -> bool: return is_same_types(left.items, cast(UnionType, self.right).items) else: return False + + def visit_overloaded(self, left: Overloaded) -> bool: + if isinstance(self.right, Overloaded): + return is_same_types(cast(List[Type], left.items()), + cast(List[Type], cast(Overloaded, self.right).items())) + else: + return False diff --git a/mypy/semanal.py b/mypy/semanal.py index 22e1467dfe3b..a854a748a040 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -75,7 +75,7 @@ from mypy.lex import lex from mypy.parsetype import parse_type from mypy.sametypes import is_same_type -from mypy import defaults +from mypy.syntax.dialect import Dialect, default_dialect T = TypeVar('T') @@ -165,7 +165,7 @@ class SemanticAnalyzer(NodeVisitor): errors = None # type: Errors # Keeps track of generated errors def __init__(self, lib_path: List[str], errors: Errors, - pyversion: Tuple[int, int] = defaults.PYTHON3_VERSION) -> None: + dialect: Dialect = default_dialect()) -> None: """Construct semantic analyzer. Use lib_path to search for modules, and report analysis errors @@ -183,7 +183,7 @@ def __init__(self, lib_path: List[str], errors: Errors, self.lib_path = lib_path self.errors = errors self.modules = {} - self.pyversion = pyversion + self.dialect = dialect def visit_file(self, file_node: MypyFile, fnam: str) -> None: self.errors.set_file(fnam) @@ -536,7 +536,7 @@ def setup_type_promotion(self, defn: ClassDef) -> None: # _promote class decorator (undocumented faeture). promote_target = analyzed.type if not promote_target: - promotions = (TYPE_PROMOTIONS_PYTHON3 if self.pyversion[0] >= 3 + promotions = (TYPE_PROMOTIONS_PYTHON3 if self.dialect.major >= 3 else TYPE_PROMOTIONS_PYTHON2) if defn.fullname in promotions: promote_target = self.named_type_or_none(promotions[defn.fullname]) @@ -1456,7 +1456,7 @@ def visit_continue_stmt(self, s: ContinueStmt) -> None: self.fail("'continue' outside loop", s) def visit_if_stmt(self, s: IfStmt) -> None: - infer_reachability_of_if_statement(s, pyversion=self.pyversion) + infer_reachability_of_if_statement(s, dialect=self.dialect) for i in range(len(s.expr)): s.expr[i].accept(self) self.visit_block(s.body[i]) @@ -1986,7 +1986,7 @@ class FirstPass(NodeVisitor): def __init__(self, sem: SemanticAnalyzer) -> None: self.sem = sem - self.pyversion = sem.pyversion + self.dialect = sem.dialect def analyze(self, file: MypyFile, fnam: str, mod_id: str) -> None: """Perform the first analysis pass. @@ -2087,7 +2087,7 @@ def visit_decorator(self, d: Decorator) -> None: self.sem.add_symbol(d.var.name(), SymbolTableNode(GDEF, d.var), d) def visit_if_stmt(self, s: IfStmt) -> None: - infer_reachability_of_if_statement(s, pyversion=self.pyversion) + infer_reachability_of_if_statement(s, dialect=self.dialect) for node in s.body: node.accept(self) if s.else_body: @@ -2230,9 +2230,9 @@ def remove_imported_names_from_symtable(names: SymbolTable, def infer_reachability_of_if_statement(s: IfStmt, - pyversion: Tuple[int, int]) -> None: + dialect: Dialect) -> None: for i in range(len(s.expr)): - result = infer_if_condition_value(s.expr[i], pyversion) + result = infer_if_condition_value(s.expr[i], dialect) if result == ALWAYS_FALSE: # The condition is always false, so we skip the if/elif body. mark_block_unreachable(s.body[i]) @@ -2246,7 +2246,7 @@ def infer_reachability_of_if_statement(s: IfStmt, break -def infer_if_condition_value(expr: Node, pyversion: Tuple[int, int]) -> int: +def infer_if_condition_value(expr: Node, dialect: Dialect) -> int: """Infer whether if condition is always true/false. Return ALWAYS_TRUE if always true, ALWAYS_FALSE if always false, @@ -2265,9 +2265,9 @@ def infer_if_condition_value(expr: Node, pyversion: Tuple[int, int]) -> int: name = expr.name result = TRUTH_VALUE_UNKNOWN if name == 'PY2': - result = ALWAYS_TRUE if pyversion[0] == 2 else ALWAYS_FALSE + result = ALWAYS_TRUE if dialect.major == 2 else ALWAYS_FALSE elif name == 'PY3': - result = ALWAYS_TRUE if pyversion[0] == 3 else ALWAYS_FALSE + result = ALWAYS_TRUE if dialect.major == 3 else ALWAYS_FALSE elif name == 'MYPY': result = ALWAYS_TRUE if negated: diff --git a/mypy/stats.py b/mypy/stats.py index 1a493d842914..ada96f7ad1e5 100644 --- a/mypy/stats.py +++ b/mypy/stats.py @@ -223,7 +223,7 @@ def dump_type_stats(tree: Node, path: str, inferred: bool = False, def is_special_module(path: str) -> bool: - return os.path.basename(path) in ('abc.py', 'typing.py', 'builtins.py') + return os.path.basename(path) in ('abc.pyi', 'typing.pyi', 'builtins.pyi') def is_imprecise(t: Type) -> bool: diff --git a/mypy/stubgen.py b/mypy/stubgen.py index f798e1bb418d..a25b3d3b132d 100644 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -39,7 +39,7 @@ import mypy.parse import mypy.errors import mypy.traverser -from mypy import defaults +from mypy.syntax.dialect import Dialect, default_dialect, default_implementation from mypy.nodes import ( IntExpr, UnaryExpr, StrExpr, BytesExpr, NameExpr, FloatExpr, MemberExpr, TupleExpr, ListExpr, ComparisonExpr, CallExpr, ClassDef, ARG_STAR, ARG_STAR2, ARG_NAMED @@ -49,17 +49,17 @@ def generate_stub(path, output_dir, _all_=None, target=None, add_header=False, module=None, - pyversion=defaults.PYTHON3_VERSION): + dialect=default_dialect()): source = open(path, 'rb').read() try: - ast = mypy.parse.parse(source, fnam=path, pyversion=pyversion) + ast = mypy.parse.parse(source, fnam=path, dialect=dialect) except mypy.errors.CompileError as e: # Syntax error! for m in e.messages: sys.stderr.write('%s\n' % m) exit(1) - gen = StubGenerator(_all_, pyversion=pyversion) + gen = StubGenerator(_all_, dialect=dialect) ast.accept(gen) if not target: target = os.path.join(output_dir, os.path.basename(path)) @@ -68,13 +68,13 @@ def generate_stub(path, output_dir, _all_=None, target=None, add_header=False, m os.makedirs(subdir) with open(target, 'w') as file: if add_header: - write_header(file, module, pyversion=pyversion) + write_header(file, module, dialect=dialect) file.write(''.join(gen.output())) def generate_stub_for_module(module, output_dir, quiet=False, add_header=False, sigs={}, - class_sigs={}, pyversion=defaults.PYTHON3_VERSION): - if pyversion[0] == 2: + class_sigs={}, dialect=default_dialect()): + if dialect.major == 2: module_path, module_all = load_python2_module_info(module) else: mod = importlib.import_module(module) @@ -97,7 +97,7 @@ def generate_stub_for_module(module, output_dir, quiet=False, add_header=False, target += '.pyi' target = os.path.join(output_dir, target) generate_stub(module_path, output_dir, module_all, - target=target, add_header=add_header, module=module, pyversion=pyversion) + target=target, add_header=add_header, module=module, dialect=dialect) if not quiet: print('Created %s' % target) @@ -143,7 +143,7 @@ def load_python2_module_info(module): class StubGenerator(mypy.traverser.TraverserVisitor): - def __init__(self, _all_, pyversion): + def __init__(self, _all_, dialect=default_dialect()): self._all_ = _all_ self._output = [] self._import_lines = [] @@ -154,7 +154,7 @@ def __init__(self, _all_, pyversion): self._toplevel_names = [] self._classes = [] self._base_classes = [] - self._pyversion = pyversion + self._dialect = dialect def visit_mypy_file(self, o): self._classes = find_classes(o) @@ -470,7 +470,7 @@ def main(): args = sys.argv[1:] sigs = {} class_sigs = {} - pyversion = defaults.PYTHON3_VERSION + dialect = default_implementation().base_dialect while args and args[0].startswith('--'): if args[0] == '--docpath': docpath = args[1] @@ -484,7 +484,7 @@ def main(): sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) elif args[0] == '--py2': - pyversion = defaults.PYTHON2_VERSION + dialect = default_implementation(force_py2=True).base_dialect else: raise SystemExit('Unrecognized option %s' % args[0]) args = args[1:] @@ -492,7 +492,7 @@ def main(): usage() for module in args: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs, - pyversion=pyversion) + dialect=dialect) def usage(): diff --git a/mypy/stubutil.py b/mypy/stubutil.py index b2547987abe1..f7bef2c58802 100644 --- a/mypy/stubutil.py +++ b/mypy/stubutil.py @@ -1,6 +1,8 @@ import re import sys +from mypy.syntax.dialect import default_dialect + def parse_signature(sig): m = re.match(r'([.a-zA-Z0-9_]+)\(([^)]*)\)', sig) @@ -78,13 +80,9 @@ def is_c_module(module): return '__file__' not in module.__dict__ or module.__dict__['__file__'].endswith('.so') -def write_header(file, module_name, pyversion=(3, 5)): +def write_header(file, module_name, dialect=default_dialect()): if module_name: - if pyversion[0] >= 3: - version = '%d.%d' % (sys.version_info.major, - sys.version_info.minor) - else: - version = '2' + version = '%d.%d' % (dialect.major, dialect.minor) file.write('# Stubs for %s (Python %s)\n' % (module_name, version)) file.write( '#\n' diff --git a/mypy/syntax/__init__.py b/mypy/syntax/__init__.py new file mode 100644 index 000000000000..fa4000266849 --- /dev/null +++ b/mypy/syntax/__init__.py @@ -0,0 +1 @@ +# This page intentionally left blank diff --git a/mypy/syntax/dialect.py b/mypy/syntax/dialect.py new file mode 100644 index 000000000000..4fbffb146980 --- /dev/null +++ b/mypy/syntax/dialect.py @@ -0,0 +1,142 @@ +"""Python dialect control. + +This may be incomplet or inkorrekt. + +Versions < 2.7 is not a priority. +Versions >= 3.0 and < 3.2 are not a priority. +Versions < 2.4 have many fundamental differences. +Versions < 2.2 have even more fundamental differences. +Versions 1.6 and 2.0 are not distinguished. +Versions < 1.6 are not even mentioned. +""" + + +from typing import ( + List, + Sequence, + Set, + Tuple, +) + +import os +import platform +import subprocess +import sys + + +# Maintain our own copy instead of using __future__ just in case we need +# to parse a newer version of python than we're running. +# Also we can add artificial ones. + +available_futures = { + # Internal pseudo-futures. + 'mypy-codec': '0.0', + 'mypy-stub': '0.0', + 'mypy-instring': '0.0', + + # Pseudo-futures from platform.python_implementation(). + # Note that only PyPy and CPython are tested. + 'variant-CPython': '0.0', + 'variant-PyPy': '0.0', + 'variant-Jython': '0.0', + 'variant-IronPython': '0.0', + + # Real features from the __future__ module. + 'nested_scopes': '2.1', + 'generators': '2.2', + 'division': '2.2', + 'absolute_import': '2.5', + 'with_statement': '2.5', + 'print_function': '2.6', + 'unicode_literals': '2.6', + 'barry_as_FLUFL': '3.1', +} + + +def check_futures(version: str, futures: Sequence[str]) -> Set[str]: + for fut in futures: + assert version >= available_futures[fut] + return set(futures) + + +class Dialect: + + def __init__(self, version: str, future_list: Sequence[str] = []) -> None: + """Construct a dialect for the given Python version and future set. + + `version` is like `'2.7.0'`, e.g. `platform.python_version()`. + `future_list` is like `['X', 'Y', 'Z']` in `from __future__ import X, Y, Z`. + """ + version = version.rstrip('+') + self.major, self.minor, self.patchlevel = [int(x) for x in version.split('.')] + future_set = check_futures(version, future_list) + self.base_version = version + self.base_future_list = future_list + self.base_future_set = future_set + + self.possible_futures = {k for (k, v) in available_futures.items() if v <= version} + + # Lexer + self.ellipsis = version >= '3.0' or 'mypy-stub' in future_set + + # Parser + + + # Additional members will be set as needed by the lexer, parser, etc. + + + def __repr__(self) -> str: + return 'Dialect(%r, %r)' % (self.base_version, self.base_future_list) + + def add_future(self, future: str) -> 'Dialect': + if future in self.base_future_set: + return self + return Dialect(self.base_version, list(self.base_future_list) + [future]) + + +class Implementation: + + def __init__(self, executable: str) -> None: + command = '''if True: + import platform, sys + print((platform.python_implementation(), platform.python_version(), sys.path)) + ''' + output = subprocess.check_output([executable, '-c', command]) + impl, version, path = eval(output) # type: Tuple[str, str, List[str]] + + self.executable = executable + self.base_dialect = Dialect(version, ['variant-' + impl]) + self.stub_dialect = self.base_dialect.add_future('mypy-stub') + self.python_path = path + # TODO self.stub_path = [] + + +def default_implementation(*, force_py2: bool = False) -> Implementation: + """Return the preferred python implementation for the inferior. + + This looks at the MYPY_PYTHON environment variable, or else uses + the current python version. + + The `force_py2` argument should possibly be deprecated. + """ + if force_py2: + try_pythons = [os.getenv('MYPY_PYTHON'), 'python2', 'python2.7', 'python'] + else: + try_pythons = [os.getenv('MYPY_PYTHON'), sys.executable] + for python in try_pythons: + if python is None: + continue + try: + impl = Implementation(python) + except (OSError, subprocess.CalledProcessError): + continue + if force_py2 and impl.base_dialect.major != 2: + continue + return impl + sys.exit('No suitable python executable found') + + +def default_dialect() -> Dialect: + version = platform.python_version() + impl = platform.python_implementation() + return Dialect(version, ['variant-' + impl]) diff --git a/mypy/test/config.py b/mypy/test/config.py index 83962d6972f8..27e9b3e962b8 100644 --- a/mypy/test/config.py +++ b/mypy/test/config.py @@ -4,10 +4,8 @@ import typing -PREFIX = '' - # Location of test data files such as test case descriptions. -test_data_prefix = os.path.join(PREFIX, 'mypy', 'test', 'data') +test_data_prefix = os.path.join(os.path.dirname(__file__), 'data') assert os.path.isdir(test_data_prefix), \ 'Test data prefix ({}) not set correctly'.format(test_data_prefix) diff --git a/mypy/test/data.py b/mypy/test/data.py index 73e6b9db35bf..31351afb720c 100644 --- a/mypy/test/data.py +++ b/mypy/test/data.py @@ -47,9 +47,11 @@ def parse_test_cases( '\n'.join(p[i].data))) elif p[i].id == 'builtins': # Use a custom source file for the std module. + if p[i].arg.endswith('.py'): + p[i].arg += 'i' mpath = os.path.join(os.path.dirname(path), p[i].arg) f = open(mpath) - files.append((os.path.join(base_path, 'builtins.py'), + files.append((os.path.join(base_path, 'builtins.pyi'), f.read())) f.close() else: diff --git a/mypy/test/data/fixtures/alias.py b/mypy/test/data/fixtures/alias.pyi similarity index 100% rename from mypy/test/data/fixtures/alias.py rename to mypy/test/data/fixtures/alias.pyi diff --git a/mypy/test/data/fixtures/bool-simple.py b/mypy/test/data/fixtures/bool-simple.pyi similarity index 100% rename from mypy/test/data/fixtures/bool-simple.py rename to mypy/test/data/fixtures/bool-simple.pyi diff --git a/mypy/test/data/fixtures/bool.py b/mypy/test/data/fixtures/bool.pyi similarity index 100% rename from mypy/test/data/fixtures/bool.py rename to mypy/test/data/fixtures/bool.pyi diff --git a/mypy/test/data/fixtures/classmethod.py b/mypy/test/data/fixtures/classmethod.pyi similarity index 100% rename from mypy/test/data/fixtures/classmethod.py rename to mypy/test/data/fixtures/classmethod.pyi diff --git a/mypy/test/data/fixtures/complex.py b/mypy/test/data/fixtures/complex.pyi similarity index 100% rename from mypy/test/data/fixtures/complex.py rename to mypy/test/data/fixtures/complex.pyi diff --git a/mypy/test/data/fixtures/dict.py b/mypy/test/data/fixtures/dict.pyi similarity index 100% rename from mypy/test/data/fixtures/dict.py rename to mypy/test/data/fixtures/dict.pyi diff --git a/mypy/test/data/fixtures/exception.py b/mypy/test/data/fixtures/exception.pyi similarity index 100% rename from mypy/test/data/fixtures/exception.py rename to mypy/test/data/fixtures/exception.pyi diff --git a/mypy/test/data/fixtures/for.py b/mypy/test/data/fixtures/for.pyi similarity index 100% rename from mypy/test/data/fixtures/for.py rename to mypy/test/data/fixtures/for.pyi diff --git a/mypy/test/data/fixtures/function.py b/mypy/test/data/fixtures/function.pyi similarity index 100% rename from mypy/test/data/fixtures/function.py rename to mypy/test/data/fixtures/function.pyi diff --git a/mypy/test/data/fixtures/isinstance.py b/mypy/test/data/fixtures/isinstance.pyi similarity index 100% rename from mypy/test/data/fixtures/isinstance.py rename to mypy/test/data/fixtures/isinstance.pyi diff --git a/mypy/test/data/fixtures/isinstancelist.py b/mypy/test/data/fixtures/isinstancelist.pyi similarity index 100% rename from mypy/test/data/fixtures/isinstancelist.py rename to mypy/test/data/fixtures/isinstancelist.pyi diff --git a/mypy/test/data/fixtures/list.py b/mypy/test/data/fixtures/list.pyi similarity index 100% rename from mypy/test/data/fixtures/list.py rename to mypy/test/data/fixtures/list.pyi diff --git a/mypy/test/data/fixtures/module.py b/mypy/test/data/fixtures/module.pyi similarity index 100% rename from mypy/test/data/fixtures/module.py rename to mypy/test/data/fixtures/module.pyi diff --git a/mypy/test/data/fixtures/ops.py b/mypy/test/data/fixtures/ops.pyi similarity index 100% rename from mypy/test/data/fixtures/ops.py rename to mypy/test/data/fixtures/ops.pyi diff --git a/mypy/test/data/fixtures/primitives.py b/mypy/test/data/fixtures/primitives.pyi similarity index 100% rename from mypy/test/data/fixtures/primitives.py rename to mypy/test/data/fixtures/primitives.pyi diff --git a/mypy/test/data/fixtures/property.py b/mypy/test/data/fixtures/property.pyi similarity index 100% rename from mypy/test/data/fixtures/property.py rename to mypy/test/data/fixtures/property.pyi diff --git a/mypy/test/data/fixtures/python2.py b/mypy/test/data/fixtures/python2.pyi similarity index 100% rename from mypy/test/data/fixtures/python2.py rename to mypy/test/data/fixtures/python2.pyi diff --git a/mypy/test/data/fixtures/set.py b/mypy/test/data/fixtures/set.pyi similarity index 100% rename from mypy/test/data/fixtures/set.py rename to mypy/test/data/fixtures/set.pyi diff --git a/mypy/test/data/fixtures/slice.py b/mypy/test/data/fixtures/slice.pyi similarity index 100% rename from mypy/test/data/fixtures/slice.py rename to mypy/test/data/fixtures/slice.pyi diff --git a/mypy/test/data/fixtures/staticmethod.py b/mypy/test/data/fixtures/staticmethod.pyi similarity index 100% rename from mypy/test/data/fixtures/staticmethod.py rename to mypy/test/data/fixtures/staticmethod.pyi diff --git a/mypy/test/data/fixtures/transform.py b/mypy/test/data/fixtures/transform.pyi similarity index 100% rename from mypy/test/data/fixtures/transform.py rename to mypy/test/data/fixtures/transform.pyi diff --git a/mypy/test/data/fixtures/tuple-simple.py b/mypy/test/data/fixtures/tuple-simple.pyi similarity index 100% rename from mypy/test/data/fixtures/tuple-simple.py rename to mypy/test/data/fixtures/tuple-simple.pyi diff --git a/mypy/test/data/fixtures/tuple.py b/mypy/test/data/fixtures/tuple.pyi similarity index 100% rename from mypy/test/data/fixtures/tuple.py rename to mypy/test/data/fixtures/tuple.pyi diff --git a/mypy/test/data/fixtures/union.py b/mypy/test/data/fixtures/union.pyi similarity index 100% rename from mypy/test/data/fixtures/union.py rename to mypy/test/data/fixtures/union.pyi diff --git a/mypy/test/data/lib-stub/abc.py b/mypy/test/data/lib-stub/abc.pyi similarity index 100% rename from mypy/test/data/lib-stub/abc.py rename to mypy/test/data/lib-stub/abc.pyi diff --git a/mypy/test/data/lib-stub/builtins.py b/mypy/test/data/lib-stub/builtins.pyi similarity index 100% rename from mypy/test/data/lib-stub/builtins.py rename to mypy/test/data/lib-stub/builtins.pyi diff --git a/mypy/test/data/lib-stub/collections.py b/mypy/test/data/lib-stub/collections.pyi similarity index 100% rename from mypy/test/data/lib-stub/collections.py rename to mypy/test/data/lib-stub/collections.pyi diff --git a/mypy/test/data/lib-stub/typing.py b/mypy/test/data/lib-stub/typing.pyi similarity index 100% rename from mypy/test/data/lib-stub/typing.py rename to mypy/test/data/lib-stub/typing.pyi diff --git a/mypy/test/helpers.py b/mypy/test/helpers.py index b6b1e5a850cf..f5bfc2baf08f 100644 --- a/mypy/test/helpers.py +++ b/mypy/test/helpers.py @@ -4,7 +4,7 @@ from typing import List, Dict, Tuple -from mypy import defaults +from mypy.syntax.dialect import Implementation, default_implementation from mypy.myunit import AssertionFailure from mypy.test import config @@ -21,8 +21,6 @@ def assert_string_arrays_equal(expected: List[str], actual: List[str], Display any differences in a human-readable form. """ - actual = clean_up(actual) - if actual != expected: num_skip_start = num_skipped_prefix_lines(expected, actual) num_skip_end = num_skipped_suffix_lines(expected, actual) @@ -171,7 +169,6 @@ def assert_string_arrays_equal_wildcards(expected: List[str], msg: str) -> None: # Like above, but let a line with only '...' in expected match any number # of lines in actual. - actual = clean_up(actual) while actual != [] and actual[-1] == '': actual = actual[:-1] @@ -181,25 +178,6 @@ def assert_string_arrays_equal_wildcards(expected: List[str], assert_string_arrays_equal(expected, actual, msg) -def clean_up(a): - """Remove common directory prefix from all strings in a. - - This uses a naive string replace; it seems to work well enough. Also - remove trailing carriage returns. - """ - res = [] - for s in a: - prefix = config.PREFIX + os.sep - ss = s - for p in prefix, prefix.replace(os.sep, '/'): - if p != '/' and p != '//' and p != '\\' and p != '\\\\': - ss = ss.replace(p, '') - # Ignore spaces at end of line. - ss = re.sub(' +$', '', ss) - res.append(re.sub('\\r$', '', ss)) - return res - - def match_array(pattern: List[str], target: List[str]) -> List[str]: """Expand '...' wildcards in pattern by matching against target.""" @@ -261,15 +239,21 @@ def num_skipped_suffix_lines(a1: List[str], a2: List[str]) -> int: return max(0, num_eq - 4) -def testfile_pyversion(path: str) -> Tuple[int, int]: +DEFAULT_IMPLEMENTATION_PYTHON2 = default_implementation(force_py2=True) +DEFAULT_IMPLEMENTATION_PYTHON3 = default_implementation() +assert DEFAULT_IMPLEMENTATION_PYTHON2.base_dialect.major == 2 +assert DEFAULT_IMPLEMENTATION_PYTHON3.base_dialect.major == 3 + + +def testfile_python_implementation(path: str) -> Implementation: if path.endswith('python2.test'): - return defaults.PYTHON2_VERSION + return DEFAULT_IMPLEMENTATION_PYTHON2 else: - return defaults.PYTHON3_VERSION + return DEFAULT_IMPLEMENTATION_PYTHON3 -def testcase_pyversion(path: str, testcase_name: str) -> Tuple[int, int]: +def testcase_python_implementation(path: str, testcase_name: str) -> Implementation: if testcase_name.endswith('python2'): - return defaults.PYTHON2_VERSION + return DEFAULT_IMPLEMENTATION_PYTHON2 else: - return testfile_pyversion(path) + return testfile_python_implementation(path) diff --git a/mypy/test/testcheck.py b/mypy/test/testcheck.py index 4fc83b1411f0..6054d67d3daf 100644 --- a/mypy/test/testcheck.py +++ b/mypy/test/testcheck.py @@ -12,7 +12,7 @@ from mypy.test.config import test_temp_dir, test_data_prefix from mypy.test.data import parse_test_cases from mypy.test.helpers import ( - assert_string_arrays_equal, testcase_pyversion, update_testcase_output + assert_string_arrays_equal, testcase_python_implementation, update_testcase_output ) from mypy.test.testsemanal import normalize_error_messages from mypy.errors import CompileError @@ -64,7 +64,7 @@ def cases(self): def run_test(self, testcase): a = [] - pyversion = testcase_pyversion(testcase.file, testcase.name) + implementation = testcase_python_implementation(testcase.file, testcase.name) program_text = '\n'.join(testcase.input) module_name, program_name, program_text = self.parse_options(program_text) try: @@ -72,7 +72,7 @@ def run_test(self, testcase): target=build.TYPE_CHECK, module=module_name, program_text=program_text, - pyversion=pyversion, + implementation=implementation, flags=[build.TEST_BUILTINS], alt_lib_path=test_temp_dir) except CompileError as e: diff --git a/mypy/test/testparse.py b/mypy/test/testparse.py index 56b7523ad4cd..ba309fefa2bd 100644 --- a/mypy/test/testparse.py +++ b/mypy/test/testparse.py @@ -6,7 +6,7 @@ import typing -from mypy import defaults +from mypy.syntax.dialect import Dialect, default_dialect from mypy.myunit import Suite, AssertionFailure from mypy.test.helpers import assert_string_arrays_equal from mypy.test.data import parse_test_cases @@ -35,12 +35,12 @@ def test_parser(testcase): """ if testcase.file.endswith('python2.test'): - pyversion = defaults.PYTHON2_VERSION + dialect = Dialect('2.7.0') else: - pyversion = defaults.PYTHON3_VERSION + dialect = default_dialect() try: - n = parse(bytes('\n'.join(testcase.input), 'ascii'), pyversion=pyversion, fnam='main') + n = parse(bytes('\n'.join(testcase.input), 'ascii'), dialect=dialect, fnam='main') a = str(n).split('\n') except CompileError as e: a = e.messages diff --git a/mypy/test/testpythoneval.py b/mypy/test/testpythoneval.py index 07a4a0dc4f47..48f45b51c51b 100644 --- a/mypy/test/testpythoneval.py +++ b/mypy/test/testpythoneval.py @@ -17,6 +17,7 @@ import typing +from mypy.build import is_installed from mypy.myunit import Suite, SkipTestCaseException from mypy.test.config import test_data_prefix, test_temp_dir from mypy.test.data import parse_test_cases @@ -72,7 +73,7 @@ def test_python_evaluation(testcase): # Type check the program. # This uses the same PYTHONPATH as the current process. process = subprocess.Popen([python3_path, - os.path.join(testcase.old_cwd, 'scripts', 'mypy')] + '-m', 'mypy'] + args + [program], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -83,11 +84,14 @@ def test_python_evaluation(testcase): if not process.wait(): # Set up module path for the execution. # This needs the typing module but *not* the mypy module. - vers_dir = '2.7' if py2 else '3.2' - typing_path = os.path.join(testcase.old_cwd, 'lib-typing', vers_dir) - assert os.path.isdir(typing_path) - env = os.environ.copy() - env['PYTHONPATH'] = typing_path + if is_installed(): + env = None + else: + vers_dir = '2.7' if py2 else '3.2' + typing_path = os.path.join(testcase.old_cwd, 'lib-typing', vers_dir) + assert os.path.isdir(typing_path) + env = os.environ.copy() + env['PYTHONPATH'] = typing_path process = subprocess.Popen([interpreter, program], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -110,6 +114,10 @@ def try_find_python2_interpreter(): stderr=subprocess.STDOUT) stdout, stderr = process.communicate() if b'Python 2.7' in stdout: + if is_installed(): + print('WARNING: python2 interpreter found, but' + ' typing is not installed for python2') + return None return interpreter except OSError: pass diff --git a/mypy/test/testsemanal.py b/mypy/test/testsemanal.py index 3a9c14bccce3..ddd547167010 100644 --- a/mypy/test/testsemanal.py +++ b/mypy/test/testsemanal.py @@ -6,7 +6,7 @@ from mypy import build from mypy.myunit import Suite -from mypy.test.helpers import assert_string_arrays_equal, testfile_pyversion +from mypy.test.helpers import assert_string_arrays_equal, testfile_python_implementation from mypy.test.data import parse_test_cases from mypy.test.config import test_data_prefix, test_temp_dir from mypy.errors import CompileError @@ -49,7 +49,7 @@ def test_semanal(testcase): result = build.build('main', target=build.SEMANTIC_ANALYSIS, program_text=src, - pyversion=testfile_pyversion(testcase.file), + implementation=testfile_python_implementation(testcase.file), flags=[build.TEST_BUILTINS], alt_lib_path=test_temp_dir) a = [] @@ -60,10 +60,10 @@ def test_semanal(testcase): # Omit the builtins module and files with a special marker in the # path. # TODO the test is not reliable - if (not f.path.endswith((os.sep + 'builtins.py', - 'typing.py', - 'abc.py', - 'collections.py')) + if (not f.path.endswith((os.sep + 'builtins.pyi', + 'typing.pyi', + 'abc.pyi', + 'collections.pyi')) and not os.path.basename(f.path).startswith('_') and not os.path.splitext( os.path.basename(f.path))[0].endswith('_')): diff --git a/mypy/test/testtransform.py b/mypy/test/testtransform.py index eaab12cb1de8..57eaf4b12ec1 100644 --- a/mypy/test/testtransform.py +++ b/mypy/test/testtransform.py @@ -6,7 +6,7 @@ from mypy import build from mypy.myunit import Suite -from mypy.test.helpers import assert_string_arrays_equal, testfile_pyversion +from mypy.test.helpers import assert_string_arrays_equal, testfile_python_implementation from mypy.test.data import parse_test_cases from mypy.test.config import test_data_prefix, test_temp_dir from mypy.errors import CompileError @@ -41,7 +41,7 @@ def test_transform(testcase): result = build.build('main', target=build.SEMANTIC_ANALYSIS, program_text=src, - pyversion=testfile_pyversion(testcase.file), + implementation=testfile_python_implementation(testcase.file), flags=[build.TEST_BUILTINS], alt_lib_path=test_temp_dir) a = [] @@ -53,9 +53,9 @@ def test_transform(testcase): # Omit the builtins module and files with a special marker in the # path. # TODO the test is not reliable - if (not f.path.endswith((os.sep + 'builtins.py', - 'typing.py', - 'abc.py')) + if (not f.path.endswith((os.sep + 'builtins.pyi', + 'typing.pyi', + 'abc.pyi')) and not os.path.basename(f.path).startswith('_') and not os.path.splitext( os.path.basename(f.path))[0].endswith('_')): diff --git a/mypy/typeanal.py b/mypy/typeanal.py index 2c07b0fb681d..9a1b2d9ca199 100644 --- a/mypy/typeanal.py +++ b/mypy/typeanal.py @@ -347,3 +347,6 @@ def visit_type_list(self, t: TypeList) -> None: def visit_type_var(self, t: TypeVarType) -> None: pass + + def visit_star_type(self, t: StarType) -> None: + pass diff --git a/mypy/types.py b/mypy/types.py index 491b01a1b1aa..2e57fd434819 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -499,50 +499,65 @@ class TypeVisitor(Generic[T]): The parameter T is the return type of the visit methods. """ + def _notimplemented_helper(self) -> NotImplementedError: + return NotImplementedError("Method visit_type_list not implemented in " + + "'{}'\n".format(type(self).__name__) + + "This is a known bug, track development in " + + "'https://github.com/JukkaL/mypy/issues/730'") + + @abstractmethod def visit_unbound_type(self, t: UnboundType) -> T: pass def visit_type_list(self, t: TypeList) -> T: - pass + raise self._notimplemented_helper() def visit_error_type(self, t: ErrorType) -> T: - pass + raise self._notimplemented_helper() + @abstractmethod def visit_any(self, t: AnyType) -> T: pass + @abstractmethod def visit_void(self, t: Void) -> T: pass + @abstractmethod def visit_none_type(self, t: NoneTyp) -> T: pass def visit_erased_type(self, t: ErasedType) -> T: - pass + raise self._notimplemented_helper() + @abstractmethod def visit_type_var(self, t: TypeVarType) -> T: pass + @abstractmethod def visit_instance(self, t: Instance) -> T: pass + @abstractmethod def visit_callable_type(self, t: CallableType) -> T: pass def visit_overloaded(self, t: Overloaded) -> T: - pass + raise self._notimplemented_helper() + @abstractmethod def visit_tuple_type(self, t: TupleType) -> T: pass def visit_star_type(self, t: StarType) -> T: - pass + raise self._notimplemented_helper() + @abstractmethod def visit_union_type(self, t: UnionType) -> T: pass def visit_ellipsis_type(self, t: EllipsisType) -> T: - assert False # XXX catch visitors that don't have this implemented yet + raise self._notimplemented_helper() class TypeTranslator(TypeVisitor[Type]): @@ -616,6 +631,10 @@ def translate_variables(self, variables: List[TypeVarDef]) -> List[TypeVarDef]: return variables + def visit_overloaded(self, type: Overloaded) -> Type: + items = [t.accept(self) for t in type.items()] # type: ignore + return Overloaded(items=cast(List[CallableType], items)) + class TypeStrVisitor(TypeVisitor[str]): """Visitor for pretty-printing types into strings. @@ -812,6 +831,9 @@ def visit_star_type(self, t: StarType) -> bool: def visit_union_type(self, t: UnionType) -> bool: return self.query_types(t.items) + def visit_overloaded(self, t: Overloaded) -> bool: + return self.query_types(cast(List[Type], t.items())) + def query_types(self, types: List[Type]) -> bool: """Perform a query for a list of types. diff --git a/runtests.py b/runtests.py index 462fa1491369..29798017f5e4 100755 --- a/runtests.py +++ b/runtests.py @@ -6,7 +6,16 @@ if True: # When this is run as a script, `typing` is not available yet. import sys - from os.path import join, isdir + from os.path import ( + basename, + dirname, + isabs, + isdir, + join, + realpath, + relpath, + splitext, + ) def get_versions(): # type: () -> typing.List[str] major = sys.version_info[0] @@ -31,6 +40,10 @@ def get_versions(): # type: () -> typing.List[str] import os +# Allow this to be symlinked to support running an installed version. +SOURCE_DIR = dirname(realpath(__file__)) + + # Ideally, all tests would be `discover`able so that they can be driven # (and parallelized) by an external test driver. @@ -45,7 +58,6 @@ def __init__(self, whitelist: List[str], blacklist: List[str], self.waiter = Waiter(verbosity=verbosity, xfail=xfail) self.versions = get_versions() self.cwd = os.getcwd() - self.mypy = os.path.join(self.cwd, 'scripts', 'mypy') self.env = dict(os.environ) def prepend_path(self, name: str, paths: List[str]) -> None: @@ -74,7 +86,7 @@ def add_mypy(self, name: str, *args: str, cwd: Optional[str] = None) -> None: if not self.allow(name): return largs = list(args) - largs[0:0] = [sys.executable, self.mypy] + largs[0:0] = ['mypy', '--use-python-path'] env = self.env self.waiter.add(LazySubprocess(name, largs, cwd=cwd, env=env)) @@ -96,7 +108,7 @@ def add_mypy_mod(self, name: str, *args: str, cwd: Optional[str] = None) -> None if not self.allow(name): return largs = list(args) - largs[0:0] = [sys.executable, self.mypy, '-m'] + largs[0:0] = ['mypy', '--use-python-path', '-m'] env = self.env self.waiter.add(LazySubprocess(name, largs, cwd=cwd, env=env)) @@ -118,7 +130,7 @@ def add_mypy_string(self, name: str, *args: str, cwd: Optional[str] = None) -> N if not self.allow(name): return largs = list(args) - largs[0:0] = [sys.executable, self.mypy, '-c'] + largs[0:0] = ['mypy', '--use-python-path', '-c'] env = self.env self.waiter.add(LazySubprocess(name, largs, cwd=cwd, env=env)) @@ -144,6 +156,19 @@ def add_python2(self, name: str, *args: str, cwd: Optional[str] = None) -> None: env = self.env self.waiter.add(LazySubprocess(name, largs, cwd=cwd, env=env)) + def add_myunit(self, name: str, *args: str, cwd: Optional[str] = None, + script: bool = True) -> None: + name = 'run %s' % name + if not self.allow(name): + return + largs = list(args) + if script: + largs[0:0] = ['myunit'] + else: + largs[0:0] = [sys.executable, '-m' 'mypy.myunit'] + env = self.env + self.waiter.add(LazySubprocess(name, largs, cwd=cwd, env=env)) + def add_flake8(self, name: str, file: str, cwd: Optional[str] = None) -> None: name = 'lint %s' % name if not self.allow(name): @@ -159,28 +184,30 @@ def list_tasks(self) -> None: def add_basic(driver: Driver) -> None: if False: - driver.add_mypy('file setup.py', 'setup.py') - driver.add_flake8('file setup.py', 'setup.py') - driver.add_mypy('file runtests.py', 'runtests.py') - driver.add_flake8('file runtests.py', 'runtests.py') - driver.add_mypy('legacy entry script', 'scripts/mypy') - driver.add_flake8('legacy entry script', 'scripts/mypy') - driver.add_mypy('legacy myunit script', 'scripts/myunit') - driver.add_flake8('legacy myunit script', 'scripts/myunit') + driver.add_mypy('file setup.py', join(SOURCE_DIR, 'setup.py')) + driver.add_flake8('file setup.py', join(SOURCE_DIR, 'setup.py')) + driver.add_mypy('file runtests.py', join(SOURCE_DIR, 'runtests.py')) + driver.add_flake8('file runtests.py', join(SOURCE_DIR, 'runtests.py')) + driver.add_mypy('legacy entry script', join(SOURCE_DIR, 'scripts/mypy')) + driver.add_flake8('legacy entry script', join(SOURCE_DIR, 'scripts/mypy')) + driver.add_mypy('legacy myunit script', join(SOURCE_DIR, 'scripts/myunit')) + driver.add_flake8('legacy myunit script', join(SOURCE_DIR, 'scripts/myunit')) driver.add_mypy_mod('entry mod mypy', 'mypy') driver.add_mypy_mod('entry mod mypy.stubgen', 'mypy.stubgen') driver.add_mypy_mod('entry mod mypy.myunit', 'mypy.myunit') def find_files(base: str, prefix: str = '', suffix: str = '') -> List[str]: + base = join(SOURCE_DIR, base) return [join(root, f) for root, dirs, files in os.walk(base) for f in files if f.startswith(prefix) and f.endswith(suffix)] -def file_to_module(file: str) -> str: - rv = os.path.splitext(file)[0].replace(os.sep, '.') +def file_to_module(file: str, ignore: str = '') -> str: + file = relpath(file, join(SOURCE_DIR, ignore)) + rv = splitext(file)[0].replace(os.sep, '.') if rv.endswith('.__init__'): rv = rv[:-len('.__init__')] return rv @@ -210,9 +237,12 @@ def add_myunit(driver: Driver) -> None: elif mod == 'mypy.test.testpythoneval': # Run Python evaluation integration tests separetely since they are much slower # than proper unit tests. - driver.add_python_mod('eval-test %s' % mod, 'mypy.myunit', '-m', mod, *driver.arglist) + + # testpythoneval requires lib-typing/2.7 to be available. Ick! + driver.add_myunit('eval-test %s' % mod, '-m', mod, *driver.arglist, + cwd=SOURCE_DIR, script=False) else: - driver.add_python_mod('unit-test %s' % mod, 'mypy.myunit', '-m', mod, *driver.arglist) + driver.add_myunit('unit-test %s' % mod, '-m', mod, *driver.arglist) def add_stubs(driver: Driver) -> None: @@ -221,9 +251,9 @@ def add_stubs(driver: Driver) -> None: seen = set() # type: Set[str] for version in driver.versions: for pfx in ['', 'third-party-']: - stubdir = join('stubs', pfx + version) + stubdir = join('mypy/data/stubs', pfx + version) for f in find_files(stubdir, suffix='.pyi'): - module = file_to_module(f[len(stubdir) + 1:]) + module = file_to_module(f, stubdir) if module not in seen: seen.add(module) driver.add_mypy_string( @@ -234,27 +264,28 @@ def add_stubs(driver: Driver) -> None: def add_libpython(driver: Driver) -> None: seen = set() # type: Set[str] for version in driver.versions: - libpython_dir = join(driver.cwd, 'lib-python', version) - for f in find_files(libpython_dir, prefix='test_', suffix='.py'): - module = file_to_module(f[len(libpython_dir) + 1:]) + libpython_dir = join('lib-python', version) + for f in find_files(libpython_dir, prefix='test_', suffix='.pyi'): + module = file_to_module(f, libpython_dir) if module not in seen: seen.add(module) driver.add_mypy_mod( 'libpython (%s) module %s' % (version, module), module, - cwd=libpython_dir) + cwd=join(SOURCE_DIR, libpython_dir)) def add_samples(driver: Driver) -> None: for f in find_files('samples', suffix='.py'): if 'codec' in f: - cwd, bf = os.path.dirname(f), os.path.basename(f) + cwd, bf = dirname(f), basename(f) bf = bf[:-len('.py')] driver.add_mypy_string('codec file %s' % f, 'import mypy.codec.register, %s' % bf, cwd=cwd) else: - driver.add_mypy('file %s' % f, f) + f = relpath(f, SOURCE_DIR) + driver.add_mypy('file %s' % f, f, cwd=SOURCE_DIR) def usage(status: int) -> None: @@ -276,7 +307,7 @@ def sanity() -> None: return failed = False for p in paths.split(os.pathsep): - if not os.path.isabs(p): + if not isabs(p): print('Relative PYTHONPATH entry %r' % p) failed = True if failed: @@ -328,18 +359,26 @@ def main() -> None: whitelist.append('') driver = Driver(whitelist=whitelist, blacklist=blacklist, arglist=arglist, - verbosity=verbosity, xfail=[]) + verbosity=verbosity, xfail=[ + 'run2 unittest mypy.codec.test.test_function_translation', + ]) driver.prepend_path('PATH', [join(driver.cwd, 'scripts')]) driver.prepend_path('MYPYPATH', [driver.cwd]) driver.prepend_path('PYTHONPATH', [driver.cwd]) driver.prepend_path('PYTHONPATH', [join(driver.cwd, 'lib-typing', v) for v in driver.versions]) - add_basic(driver) - add_myunit(driver) - add_imports(driver) - add_stubs(driver) - add_libpython(driver) - add_samples(driver) + for adder in [ + add_basic, + add_myunit, + add_imports, + add_stubs, + add_libpython, + add_samples, + ]: + before = len(driver.waiter.queue) + adder(driver) + if whitelist == [''] and blacklist == []: + assert len(driver.waiter.queue) != before, 'no tasks in %s' % adder.__name__ if not list_only: driver.waiter.run() diff --git a/setup.py b/setup.py index 0a0caa15075a..3a7b8103c759 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import os.path import sys -from distutils.core import setup +from setuptools import setup, find_packages from mypy.version import __version__ if sys.version_info < (3, 2, 0): @@ -27,7 +27,22 @@ '''.lstrip() -def find_data_files(base, globs): +classifiers = [ + 'Development Status :: 2 - Pre-Alpha', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Topic :: Software Development', +] + +packages = find_packages(exclude=['pinfer']) + + +def find_data_dirs(base, globs, cut): """Find all interesting data files, for setup(data_files=) Arguments: @@ -35,36 +50,25 @@ def find_data_files(base, globs): globs: A list of glob patterns to accept files. """ - rv_dirs = [root for root, dirs, files in os.walk(base)] + rv_dirs = [os.path.relpath(root, cut) for root, dirs, files in os.walk(base)] rv = [] for rv_dir in rv_dirs: - files = [] for pat in globs: - files += glob.glob(os.path.join(rv_dir, pat)) - if not files: - continue - target = os.path.join('lib', 'mypy', rv_dir) - rv.append((target, files)) - + rv.append(os.path.join(rv_dir, pat)) return rv -data_files = [] - -data_files += find_data_files('stubs', ['*.py', '*.pyi']) - -data_files += find_data_files('xml', ['*.xsd', '*.xslt', '*.css']) - -classifiers = [ - 'Development Status :: 2 - Pre-Alpha', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: POSIX', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Topic :: Software Development', -] +package_data = { + 'mypy': find_data_dirs('mypy/data', ['*.pyi'], 'mypy') + [ + 'xml/*.xsd', + 'xml/*.xslt', + 'xml/*.css', + ], + 'mypy.test': [ + 'data/*.test', + 'data/fixtures/*.pyi', + 'data/lib-stub/*.pyi', + ], +} setup(name='mypy-lang', version=version, @@ -77,8 +81,8 @@ def find_data_files(base, globs): platforms=['POSIX'], package_dir={'': 'lib-typing/3.2', 'mypy': 'mypy'}, py_modules=['typing'], - packages=['mypy'], - scripts=['scripts/mypy'], - data_files=data_files, + packages=packages, + scripts=['scripts/mypy', 'scripts/myunit'], + package_data=package_data, classifiers=classifiers, ) diff --git a/stubs/3.2/platform.pyi b/stubs/3.2/platform.pyi deleted file mode 100644 index 13d443b8ab8c..000000000000 --- a/stubs/3.2/platform.pyi +++ /dev/null @@ -1,9 +0,0 @@ -# Stubs for platform - -# NOTE: These are incomplete! - -from typing import Tuple - -def mac_ver(release: str = '', - version_info: Tuple[str, str, str] = ('', '', ''), - machine: str = '') -> Tuple[str, Tuple[str, str, str], str]: ... diff --git a/setup.cfg b/tox.ini similarity index 60% rename from setup.cfg rename to tox.ini index 4818cec154a6..3a784de32313 100644 --- a/setup.cfg +++ b/tox.ini @@ -1,3 +1,14 @@ +[tox] +envlist = py32,py33,py34,py35,pypy3 +[testenv] +deps = -rtest-requirements.txt +whitelist_externals = mkdir + ln + sh +commands = mkdir -p elsewhere/tmp-test-dirs + ln -sf ../runtests.py elsewhere/ + sh -c 'cd elsewhere && python runtests.py {posargs} -v' + [flake8] max-line-length = 99 exclude = mypy/codec/*,mypy/test/data/lib-stub/*,mypy/test/data/fixtures/*