MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / get_default_version

Function get_default_version

pre_commit/languages/python.py:109–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107
108@functools.lru_cache(maxsize=1)
109def get_default_version() -> str: # pragma: no cover (platform dependent)
110 v_major = f'{sys.version_info[0]}'
111 v_minor = f'{sys.version_info[0]}.{sys.version_info[1]}'
112
113 # attempt the likely implementation exe
114 for potential in (v_minor, v_major):
115 exe = f'{_impl_exe_name()}{potential}'
116 if find_executable(exe):
117 return exe
118
119 # next try `sys.executable` (or the realpath)
120 maybe_exe = _find_by_sys_executable()
121 if maybe_exe:
122 return maybe_exe
123
124 # maybe on windows we can find it via py launcher?
125 if sys.platform == 'win32': # pragma: win32 cover
126 exe = f'python{v_minor}'
127 if _find_by_py_launcher(exe):
128 return exe
129
130 # We tried!
131 return C.DEFAULT
132
133
134def _sys_executable_matches(version: str) -> bool:

Callers

nothing calls this directly

Calls 4

find_executableFunction · 0.90
_impl_exe_nameFunction · 0.85
_find_by_sys_executableFunction · 0.85
_find_by_py_launcherFunction · 0.85

Tested by

no test coverage detected