1212class VersionIncrement(IntEnum):
1313 """An enumeration representing semantic versioning increments.
1414
15- This class defines the three types of version increments according to semantic versioning:
15+ This class defines the four types of version increments according to semantic versioning:
16+ - NONE: For commits that don't require a version bump (docs, style, etc.)
1617 - PATCH: For backwards-compatible bug fixes
1718 - MINOR: For backwards-compatible functionality additions
1819 - MAJOR: For incompatible API changes
1920 """
2021
22+ NONE = auto()
2123 PATCH = auto()
2224 MINOR = auto()
2325 MAJOR = auto()
@@ -26,16 +28,16 @@ def __str__(self) -> str:
2628 return self.name
2729
2830 @classmethod
29- def safe_cast(cls, value: object) -> VersionIncrement | None :
31+ def safe_cast(cls, value: object) -> VersionIncrement:
3032 if not isinstance(value, str):
31- return None
33+ return VersionIncrement.NONE
3234 try:
3335 return cls[value]
3436 except KeyError:
35- return None
37+ return VersionIncrement.NONE
3638
37- @classmethod
38- def safe_cast_dict(cls, d: Mapping[str, object]) -> dict[str, VersionIncrement]:
39+ @staticmethod
40+ def safe_cast_dict(d: Mapping[str, object]) -> dict[str, VersionIncrement]:
3941 return {
4042 k: v
4143 for k, v in ((k, VersionIncrement.safe_cast(v)) for k, v in d.items())
@@ -45,8 +47,8 @@ def safe_cast_dict(cls, d: Mapping[str, object]) -> dict[str, VersionIncrement]:
4547 @staticmethod
4648 def get_highest_by_messages(
4749 commit_messages: Iterable[str],
48- extract_increment: Callable[[str], VersionIncrement | None ],
49- ) -> VersionIncrement | None :
50+ extract_increment: Callable[[str], VersionIncrement],
51+ ) -> VersionIncrement:
5052 """Find the highest version increment from a list of messages.
5153
5254 This function processes a list of messages and determines the highest version
@@ -76,9 +78,9 @@ def get_highest_by_messages(
7678
7779 @staticmethod
7880 def get_highest(
79- increments: Iterable[VersionIncrement | None ],
80- ) -> VersionIncrement | None :
81- return max(filter(None, increments) , default=None )
81+ increments: Iterable[VersionIncrement],
82+ ) -> VersionIncrement:
83+ return max(increments, default=VersionIncrement.NONE )
8284
8385
8486class BumpRule(Protocol):
@@ -94,7 +96,7 @@ class BumpRule(Protocol):
9496
9597 def extract_increment(
9698 self, commit_message: str, major_version_zero: bool
97- ) -> VersionIncrement | None :
99+ ) -> VersionIncrement:
98100 """Determine the version increment based on a commit message.
99101
100102 This method analyzes a commit message to determine what kind of version increment
@@ -107,24 +109,24 @@ def extract_increment(
107109 instead of MAJOR. This is useful for projects in 0.x.x versions.
108110
109111 Returns:
110- VersionIncrement | None: The type of version increment needed:
112+ VersionIncrement: The type of version increment needed:
113+ - NONE: For commits that don't require a version bump (docs, style, etc.)
111114 - MAJOR: For breaking changes when major_version_zero is False
112115 - MINOR: For breaking changes when major_version_zero is True, or for new features
113116 - PATCH: For bug fixes, performance improvements, or refactors
114- - None: For commits that don't require a version bump (docs, style, etc.)
115117 """
116118
117119
118120class ConventionalCommitBumpRule(BumpRule):
119- _BREAKING_CHANGE_TYPES = set([ "BREAKING CHANGE", "BREAKING-CHANGE"])
120- _MINOR_CHANGE_TYPES = set([ "feat"])
121- _PATCH_CHANGE_TYPES = set([ "fix", "perf", "refactor"])
121+ _BREAKING_CHANGE_TYPES = { "BREAKING CHANGE", "BREAKING-CHANGE"}
122+ _MINOR_CHANGE_TYPES = { "feat"}
123+ _PATCH_CHANGE_TYPES = { "fix", "perf", "refactor"}
122124
123125 def extract_increment(
124126 self, commit_message: str, major_version_zero: bool
125- ) -> VersionIncrement | None :
127+ ) -> VersionIncrement:
126128 if not (m := self._head_pattern.match(commit_message)):
127- return None
129+ return VersionIncrement.NONE
128130
129131 change_type = m.group("change_type")
130132 if m.group("bang") or change_type in self._BREAKING_CHANGE_TYPES:
@@ -138,7 +140,7 @@ def extract_increment(
138140 if change_type in self._PATCH_CHANGE_TYPES:
139141 return VersionIncrement.PATCH
140142
141- return None
143+ return VersionIncrement.NONE
142144
143145 @cached_property
144146 def _head_pattern(self) -> re.Pattern:
@@ -225,9 +227,9 @@ def __init__(
225227
226228 def extract_increment(
227229 self, commit_message: str, major_version_zero: bool
228- ) -> VersionIncrement | None :
230+ ) -> VersionIncrement:
229231 if not (m := self.bump_pattern.search(commit_message)):
230- return None
232+ return VersionIncrement.NONE
231233
232234 effective_bump_map = (
233235 self.bump_map_major_version_zero if major_version_zero else self.bump_map
@@ -250,4 +252,4 @@ def extract_increment(
250252 for match_pattern, increment in effective_bump_map.items():
251253 if re.match(match_pattern, found_keyword):
252254 return increment
253- return None
255+ return VersionIncrement.NONE
0 commit comments