Skip to content

Commit c3acc75

Browse files
style(bump): Enhance type annotations
Add mypy typing for _bump_with_regex and return type of _version_to_regex.
1 parent 3e19f16 commit c3acc75

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

commitizen/bump.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from collections import OrderedDict
33
from itertools import zip_longest
44
from string import Template
5-
from typing import List, Optional, Union
5+
from typing import List, Optional, Tuple, Union
66

77
from packaging.version import Version
88

@@ -167,7 +167,9 @@ def update_version_in_files(
167167
file.write("".join(version_file))
168168

169169

170-
def _bump_with_regex(version_file_contents, current_version, new_version, regex):
170+
def _bump_with_regex(
171+
version_file_contents: str, current_version: str, new_version: str, regex: str
172+
) -> Tuple[bool, str]:
171173
current_version_found = False
172174
# Bumping versions that change the string length move the offset on the file contents as finditer keeps a
173175
# reference to the initial string that was used and calling search many times would lead in infinite loops
@@ -190,7 +192,7 @@ def _bump_with_regex(version_file_contents, current_version, new_version, regex)
190192
return current_version_found, version_file_contents
191193

192194

193-
def _version_to_regex(version: str):
195+
def _version_to_regex(version: str) -> re.Pattern:
194196
clean_regex = version.replace(".", r"\.").replace("+", r"\+")
195197
return re.compile(f"{clean_regex}")
196198

0 commit comments

Comments
 (0)