MCPcopy Index your code
hub / github.com/python/mypy / install_types

Function install_types

mypy/main.py:1744–1770  ·  view source on GitHub ↗

Install stub packages using pip if some missing stubs were detected.

(
    formatter: util.FancyFormatter,
    options: Options,
    *,
    after_run: bool = False,
    non_interactive: bool = False,
)

Source from the content-addressed store, hash-verified

1742
1743
1744def install_types(
1745 formatter: util.FancyFormatter,
1746 options: Options,
1747 *,
1748 after_run: bool = False,
1749 non_interactive: bool = False,
1750) -> bool:
1751 """Install stub packages using pip if some missing stubs were detected."""
1752 packages = read_types_packages_to_install(options.cache_dir, after_run)
1753 if not packages:
1754 # If there are no missing stubs, generate no output.
1755 return False
1756 if after_run and not non_interactive:
1757 print()
1758 print("Installing missing stub packages:")
1759 assert options.python_executable, "Python executable required to install types"
1760 cmd = [options.python_executable, "-m", "pip", "install"] + packages
1761 print(formatter.style(" ".join(cmd), "none", bold=True))
1762 print()
1763 if not non_interactive:
1764 x = input("Install? [yN] ")
1765 if not x.strip() or not x.lower().startswith("y"):
1766 print(formatter.style("mypy: Skipping installation", "red", bold=True))
1767 sys.exit(2)
1768 print()
1769 subprocess.run(cmd)
1770 return True

Callers 1

mainFunction · 0.85

Calls 9

printFunction · 0.85
styleMethod · 0.80
stripMethod · 0.80
lowerMethod · 0.80
exitMethod · 0.80
joinMethod · 0.45
startswithMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…