|
1 | 1 | import os
|
2 | 2 | import re
|
| 3 | +import sys |
| 4 | +import typing |
3 | 5 | from collections import OrderedDict
|
4 | 6 | from itertools import zip_longest
|
5 | 7 | from string import Template
|
|
10 | 12 | from commitizen.defaults import MAJOR, MINOR, PATCH, bump_message
|
11 | 13 | from commitizen.exceptions import CurrentVersionNotFoundError
|
12 | 14 | 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 |
14 | 21 |
|
15 | 22 |
|
16 | 23 | def find_increment(
|
@@ -134,7 +141,8 @@ def generate_version(
|
134 | 141 | MINOR 1.0.0 -> 1.1.0
|
135 | 142 | MAJOR 1.0.0 -> 2.0.0
|
136 | 143 | """
|
137 |
| - version_type_cls = version_type_cls or Version |
| 144 | + if version_type_cls is None: |
| 145 | + version_type_cls = Version |
138 | 146 | if is_local_version:
|
139 | 147 | version = version_type_cls(current_version)
|
140 | 148 | dev_version = devrelease_generator(devrelease=devrelease)
|
@@ -226,7 +234,8 @@ def normalize_tag(
|
226 | 234 | | ver1.0.0 | 1.0.0 |
|
227 | 235 | | ver1.0.0.a0 | 1.0.0a0 |
|
228 | 236 | """
|
229 |
| - version_type_cls = version_type_cls or Version |
| 237 | + if version_type_cls is None: |
| 238 | + version_type_cls = Version |
230 | 239 | if isinstance(version, str):
|
231 | 240 | version = version_type_cls(version)
|
232 | 241 |
|
|
0 commit comments