mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
python 3.9+: use removeprefix
This commit is contained in:
parent
23a2b7360e
commit
08478ec176
4 changed files with 10 additions and 8 deletions
|
|
@ -65,7 +65,7 @@ def _find_by_py_launcher(
|
|||
version: str,
|
||||
) -> str | None: # pragma: no cover (windows only)
|
||||
if version.startswith('python'):
|
||||
num = version[len('python'):]
|
||||
num = version.removeprefix('python')
|
||||
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
|
||||
env = dict(os.environ, PYTHONIOENCODING='UTF-8')
|
||||
try:
|
||||
|
|
@ -124,7 +124,7 @@ def _sys_executable_matches(version: str) -> bool:
|
|||
return False
|
||||
|
||||
try:
|
||||
info = tuple(int(p) for p in version[len('python'):].split('.'))
|
||||
info = tuple(int(p) for p in version.removeprefix('python').split('.'))
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ def install_environment(
|
|||
|
||||
packages_to_install: set[tuple[str, ...]] = {('--path', '.')}
|
||||
for cli_dep in cli_deps:
|
||||
cli_dep = cli_dep[len('cli:'):]
|
||||
cli_dep = cli_dep.removeprefix('cli:')
|
||||
package, _, crate_version = cli_dep.partition(':')
|
||||
if crate_version != '':
|
||||
packages_to_install.add((package, '--version', crate_version))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue