Пример #1
0
    def test_walk_packages(self) -> None:
        assert_equal(set(walk_packages(["mypy.errors"])), {"mypy.errors"})

        assert_equal(set(walk_packages(["mypy.errors", "mypy.stubgen"])),
                     {"mypy.errors", "mypy.stubgen"})

        all_mypy_packages = set(walk_packages(["mypy"]))
        self.assertTrue(
            all_mypy_packages.issuperset({
                "mypy",
                "mypy.errors",
                "mypy.stubgen",
                "mypy.test",
                "mypy.test.helpers",
            }))
Пример #2
0
def find_module_paths_using_imports(modules: List[str], packages: List[str],
                                    interpreter: str,
                                    pyversion: Tuple[int, int],
                                    quiet: bool = True) -> Tuple[List[StubSource],
                                                                 List[StubSource]]:
    """Find path and runtime value of __all__ (if possible) for modules and packages.

    This function uses runtime Python imports to get the information.
    """
    py_modules = []  # type: List[StubSource]
    c_modules = []  # type: List[StubSource]
    modules = modules + list(walk_packages(packages))
    for mod in modules:
        try:
            if pyversion[0] == 2:
                result = find_module_path_and_all_py2(mod, interpreter)
            else:
                result = find_module_path_and_all_py3(mod)
        except CantImport as e:
            if not quiet:
                traceback.print_exc()
            report_missing(mod, e.message)
            continue
        if not result:
            c_modules.append(StubSource(mod))
        else:
            path, runtime_all = result
            py_modules.append(StubSource(mod, path, runtime_all))
    return py_modules, c_modules
Пример #3
0
    def test_walk_packages(self) -> None:
        assert_equal(
            set(walk_packages(["mypy.errors"])),
            {"mypy.errors"})

        assert_equal(
            set(walk_packages(["mypy.errors", "mypy.stubgen"])),
            {"mypy.errors", "mypy.stubgen"})

        all_mypy_packages = set(walk_packages(["mypy"]))
        self.assertTrue(all_mypy_packages.issuperset({
            "mypy",
            "mypy.errors",
            "mypy.stubgen",
            "mypy.test",
            "mypy.test.helpers",
        }))