예제 #1
0
파일: main.py 프로젝트: tony/mypy
def main(script_path: str) -> None:
    """Main entry point to the type checker.

    Args:
        script_path: Path to the 'mypy' script (used for finding data files).
    """
    if script_path:
        bin_dir = find_bin_directory(script_path)
    else:
        bin_dir = None
    sources, options = process_options()
    if options.pdb:
        set_drop_into_pdb(True)
    if not options.dirty_stubs:
        git.verify_git_integrity_or_abort(build.default_data_dir(bin_dir))
    f = sys.stdout
    try:
        if options.target == build.TYPE_CHECK:
            res = type_check_only(sources, bin_dir, options)
            a = res.errors
        else:
            raise RuntimeError('unsupported target %d' % options.target)
    except CompileError as e:
        a = e.messages
        if not e.use_stdout:
            f = sys.stderr
    if a:
        for m in a:
            f.write(m + '\n')
        sys.exit(1)
예제 #2
0
파일: main.py 프로젝트: gnprice/mypy
def main(script_path: str) -> None:
    """Main entry point to the type checker.

    Args:
        script_path: Path to the 'mypy' script (used for finding data files).
    """
    if script_path:
        bin_dir = find_bin_directory(script_path)
    else:
        bin_dir = None
    sources, options = process_options()
    if options.pdb:
        set_drop_into_pdb(True)
    if not options.dirty_stubs:
        git.verify_git_integrity_or_abort(build.default_data_dir(bin_dir))
    f = sys.stdout
    try:
        if options.target == build.TYPE_CHECK:
            res = type_check_only(sources, bin_dir, options)
            a = res.errors
        else:
            raise RuntimeError("unsupported target %d" % options.target)
    except CompileError as e:
        a = e.messages
        if not e.use_stdout:
            f = sys.stderr
    if a:
        for m in a:
            f.write(m + "\n")
        sys.exit(1)
예제 #3
0
파일: main.py 프로젝트: o11c/mypy
def main() -> None:
    """Main entry point to the type checker.
    """
    sources, options = process_options(sys.argv[1:])
    if not options.dirty_stubs:
        git.verify_git_integrity_or_abort(build.default_data_dir())
    try:
        if options.target == build.TYPE_CHECK:
            type_check_only(sources, options)
        else:
            raise RuntimeError('unsupported target %s' % options.target.name)
    except CompileError as e:
        for m in e.messages:
            sys.stderr.write(m + '\n')
        sys.exit(1)
예제 #4
0
def main(args: List[str]) -> Iterator[Error]:
    if len(args) == 1:
        print('must provide at least one module to test')
        sys.exit(1)
    else:
        modules = args[1:]

    options = Options()
    options.incremental = False
    data_dir = default_data_dir()
    search_path = compute_search_paths([], options, data_dir)
    find_module_cache = FindModuleCache(search_path)

    for module in modules:
        for error in test_stub(options, find_module_cache, module):
            yield error
예제 #5
0
파일: stubtest.py 프로젝트: zanellia/mypy
def build_stubs(mod):
    data_dir = default_data_dir(None)
    options = Options()
    options.python_version = (3, 6)
    lib_path = default_lib_path(data_dir,
                                options.python_version,
                                custom_typeshed_dir=None)
    sources = find_modules_recursive(mod, lib_path)
    try:
        res = build.build(sources=sources, options=options)
        messages = res.errors
    except CompileError as error:
        messages = error.messages

    if messages:
        for msg in messages:
            print(msg)
        sys.exit(1)
    return res.files
예제 #6
0
def build_stubs(mod):
    data_dir = default_data_dir(None)
    options = Options()
    options.python_version = (3, 6)
    lib_path = default_lib_path(data_dir,
                                options.python_version,
                                custom_typeshed_dir=None)
    sources = find_modules_recursive(mod, lib_path)
    try:
        res = build.build(sources=sources,
                          options=options)
        messages = res.errors
    except CompileError as error:
        messages = error.messages

    if messages:
        for msg in messages:
            print(msg)
        sys.exit(1)
    return res.files
예제 #7
0
파일: main.py 프로젝트: raph-amiard/mypy
def main(script_path: str) -> None:
    """Main entry point to the type checker.

    Args:
        script_path: Path to the 'mypy' script (used for finding data files).
    """
    if script_path:
        bin_dir = find_bin_directory(script_path)
    else:
        bin_dir = None
    sources, options = process_options(sys.argv[1:])
    if not options.dirty_stubs:
        git.verify_git_integrity_or_abort(build.default_data_dir(bin_dir))
    try:
        if options.target == build.TYPE_CHECK:
            type_check_only(sources, bin_dir, options)
        else:
            raise RuntimeError('unsupported target %d' % options.target)
    except CompileError as e:
        for m in e.messages:
            sys.stderr.write(m + '\n')
        sys.exit(1)
예제 #8
0
파일: main.py 프로젝트: yang/mypy-hack
def main(script_path: str) -> None:
    """Main entry point to the type checker.

    Args:
        script_path: Path to the 'mypy' script (used for finding data files).
    """
    if script_path:
        bin_dir = find_bin_directory(script_path)
    else:
        bin_dir = None
    sources, options = process_options(sys.argv[1:])
    if not options.dirty_stubs:
        git.verify_git_integrity_or_abort(build.default_data_dir(bin_dir))
    try:
        if options.target == build.TYPE_CHECK:
            type_check_only(sources, bin_dir, options)
        else:
            raise RuntimeError('unsupported target %d' % options.target)
    except CompileError as e:
        for m in e.messages:
            sys.stderr.write(m + '\n')
        sys.exit(1)
예제 #9
0
def build_stubs(id):
    data_dir = default_data_dir(None)
    options = Options()
    options.python_version = (3, 6)
    lib_path = default_lib_path(data_dir,
                                options.python_version,
                                custom_typeshed_dir=None)
    sources = find_modules_recursive(id, lib_path)
    if not sources:
        sys.exit('Error: Cannot find module {}'.format(repr(id)))
    msg = []
    try:
        res = build.build(sources=sources,
                          options=options)
        msg = res.errors
    except CompileError as e:
        msg = e.messages
    if msg:
        for m in msg:
            print(m)
        sys.exit(1)
    return res