Skip to content

Commit 1e6e152

Browse files
committed
Replace regex with str.removeprefix
1 parent f42353f commit 1e6e152

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sync_pre_commit_deps.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import argparse
4-
import re
54
from collections.abc import Sequence
65

76
import ruamel.yaml
@@ -56,10 +55,10 @@ def main(argv: Sequence[str] | None = None) -> int:
5655
for repo in loaded['repos']:
5756
for hook in repo['hooks']:
5857
if (hid := hook['id']) in SUPPORTED:
59-
hook_rev = re.match(r'[vV]?(?P<rev>.+)$', repo['rev'])
60-
# assert for mypy
61-
assert hook_rev is not None, f'Invalid rev {repo["rev"]!r}'
62-
versions[hid] = hook_rev.group('rev')
58+
# `mirrors-mypy` uses versions with a 'v' prefix, so we have to
59+
# strip it out to get the mypy version.
60+
cleaned_rev = repo['rev'].removeprefix('v')
61+
versions[hid] = cleaned_rev
6362

6463
updated = []
6564
for repo in loaded['repos']:

0 commit comments

Comments
 (0)