pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pre-commit/pre-commit/commit/08478ec176b705d17e3f7b0608d155e9dadff9bf

f="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> python 3.9+: use removeprefix · pre-commit/pre-commit@08478ec · GitHub
Skip to content

Commit 08478ec

Browse files
committed
python 3.9+: use removeprefix
1 parent 23a2b73 commit 08478ec

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

pre_commit/languages/python.py

Lines 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

pre_commit/languages/rust.py

Lines 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))

tests/commands/install_uninstall_test.py

Lines 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):

tests/store_test.py

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy