Skip to content

Commit 2f295cd

Browse files
committed
test(bump): VersionProtocol workaround mypy for py==3.7
Signed-off-by: apkawa <apkawa@gmail.com>
1 parent f057e3f commit 2f295cd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

commitizen/bump.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import os
22
import re
3+
import sys
4+
import typing
35
from collections import OrderedDict
46
from itertools import zip_longest
57
from string import Template
@@ -10,7 +12,12 @@
1012
from commitizen.defaults import MAJOR, MINOR, PATCH, bump_message
1113
from commitizen.exceptions import CurrentVersionNotFoundError
1214
from commitizen.git import GitCommit, smart_open
13-
from commitizen.version_types import VersionProtocol
15+
16+
if sys.version_info >= (3, 8):
17+
from commitizen.version_types import VersionProtocol
18+
else:
19+
# workaround mypy issue for 3.7 python
20+
VersionProtocol = typing.Any
1421

1522

1623
def find_increment(
@@ -134,7 +141,8 @@ def generate_version(
134141
MINOR 1.0.0 -> 1.1.0
135142
MAJOR 1.0.0 -> 2.0.0
136143
"""
137-
version_type_cls = version_type_cls or Version
144+
if version_type_cls is None:
145+
version_type_cls = Version
138146
if is_local_version:
139147
version = version_type_cls(current_version)
140148
dev_version = devrelease_generator(devrelease=devrelease)
@@ -226,7 +234,8 @@ def normalize_tag(
226234
| ver1.0.0 | 1.0.0 |
227235
| ver1.0.0.a0 | 1.0.0a0 |
228236
"""
229-
version_type_cls = version_type_cls or Version
237+
if version_type_cls is None:
238+
version_type_cls = Version
230239
if isinstance(version, str):
231240
version = version_type_cls(version)
232241

0 commit comments

Comments
 (0)