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

Function infer_python_executable

mypy/main.py:347–364  ·  view source on GitHub ↗

Infer the Python executable from the given version. This function mutates options based on special_opts to infer the correct Python executable to use.

(options: Options, special_opts: argparse.Namespace)

Source from the content-addressed store, hash-verified

345
346
347def infer_python_executable(options: Options, special_opts: argparse.Namespace) -> None:
348 """Infer the Python executable from the given version.
349
350 This function mutates options based on special_opts to infer the correct Python executable
351 to use.
352 """
353 # TODO: (ethanhs) Look at folding these checks and the site packages subprocess calls into
354 # one subprocess call for speed.
355
356 # Use the command line specified executable, or fall back to one set in the
357 # config file. If an executable is not specified, infer it from the version
358 # (unless no_executable is set)
359 python_executable = special_opts.python_executable or options.python_executable
360
361 if python_executable is None:
362 if not special_opts.no_executable and not options.no_site_packages:
363 python_executable = _python_executable_from_version(options.python_version)
364 options.python_executable = python_executable
365
366
367HEADER: Final = """%(prog)s [-h] [-v] [-V] [more options; see below]

Callers 2

process_optionsFunction · 0.85

Calls 1

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…