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

Function norm_version

pre_commit/languages/python.py:148–165  ·  view source on GitHub ↗
(version: str)

Source from the content-addressed store, hash-verified

146
147
148def norm_version(version: str) -> str | None:
149 if version == C.DEFAULT: # use virtualenv's default
150 return None
151 elif _sys_executable_matches(version): # virtualenv defaults to our exe
152 return None
153
154 if sys.platform == 'win32': # pragma: no cover (windows)
155 version_exec = _find_by_py_launcher(version)
156 if version_exec:
157 return version_exec
158
159 # Try looking up by name
160 version_exec = find_executable(version)
161 if version_exec and version_exec != version:
162 return version_exec
163
164 # Otherwise assume it is a path
165 return os.path.expanduser(version)
166
167
168@contextlib.contextmanager

Callers 1

install_environmentFunction · 0.85

Calls 3

find_executableFunction · 0.90
_sys_executable_matchesFunction · 0.85
_find_by_py_launcherFunction · 0.85

Tested by

no test coverage detected