GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python 3.9+: use removeprefix · pre-commit/pre-commit@08478ec

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pre_commit/languages
    • python.py
    • rust.py
  • tests
    • commands
      • install_uninstall_test.py
    • store_test.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pre_commit/languages/python.py‎

Copy file name to clipboardExpand all lines: pre_commit/languages/python.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _find_by_py_launcher(
6565
version: str,
6666
) -> str | None: # pragma: no cover (windows only)
6767
if version.startswith('python'):
68-
num = version[len('python'):]
68+
num = version.removeprefix('python')
6969
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
7070
env = dict(os.environ, PYTHONIOENCODING='UTF-8')
7171
try:
@@ -124,7 +124,7 @@ def _sys_executable_matches(version: str) -> bool:
124124
return False
125125

126126
try:
127-
info = tuple(int(p) for p in version[len('python'):].split('.'))
127+
info = tuple(int(p) for p in version.removeprefix('python').split('.'))
128128
except ValueError:
129129
return False
130130

Collapse file

‎pre_commit/languages/rust.py‎

Copy file name to clipboardExpand all lines: pre_commit/languages/rust.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def install_environment(
134134

135135
packages_to_install: set[tuple[str, ...]] = {('--path', '.')}
136136
for cli_dep in cli_deps:
137-
cli_dep = cli_dep[len('cli:'):]
137+
cli_dep = cli_dep.removeprefix('cli:')
138138
package, _, crate_version = cli_dep.partition(':')
139139
if crate_version != '':
140140
packages_to_install.add((package, '--version', crate_version))
Collapse file

‎tests/commands/install_uninstall_test.py‎

Copy file name to clipboardExpand all lines: tests/commands/install_uninstall_test.py
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,9 @@ def test_install_existing_hooks_no_overwrite(tempdir_factory, store):
349349
# We should run both the legacy and pre-commit hooks
350350
ret, output = _get_commit_output(tempdir_factory)
351351
assert ret == 0
352-
assert output.startswith('legacy hook\n')
353-
NORMAL_PRE_COMMIT_RUN.assert_matches(output[len('legacy hook\n'):])
352+
legacy = 'legacy hook\n'
353+
assert output.startswith(legacy)
354+
NORMAL_PRE_COMMIT_RUN.assert_matches(output.removeprefix(legacy))
354355

355356

356357
def test_legacy_overwriting_legacy_hook(tempdir_factory, store):
@@ -375,8 +376,9 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory, store):
375376
# We should run both the legacy and pre-commit hooks
376377
ret, output = _get_commit_output(tempdir_factory)
377378
assert ret == 0
378-
assert output.startswith('legacy hook\n')
379-
NORMAL_PRE_COMMIT_RUN.assert_matches(output[len('legacy hook\n'):])
379+
legacy = 'legacy hook\n'
380+
assert output.startswith(legacy)
381+
NORMAL_PRE_COMMIT_RUN.assert_matches(output.removeprefix(legacy))
380382

381383

382384
def test_install_with_existing_non_utf8_script(tmpdir, store):
Collapse file

‎tests/store_test.py‎

Copy file name to clipboardExpand all lines: tests/store_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_db_repo_name(store):
185185

186186
def test_local_resources_reflects_reality():
187187
on_disk = {
188-
res[len('empty_template_'):]
188+
res.removeprefix('empty_template_')
189189
for res in os.listdir('pre_commit/resources')
190190
if res.startswith('empty_template_')
191191
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.