-
-
Notifications
You must be signed in to change notification settings - Fork 343
Expand file tree
/
Copy pathversion_increment.py
More file actions
33 lines (25 loc) · 826 Bytes
/
version_increment.py
File metadata and controls
33 lines (25 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import annotations
from enum import IntEnum
class VersionIncrement(IntEnum):
"""Semantic versioning bump increments.
IntEnum keeps a total order compatible with NONE < PATCH < MINOR < MAJOR
for comparisons across the codebase.
- NONE: no bump (docs-only / style commits, etc.)
- PATCH: backwards-compatible bug fixes
- MINOR: backwards-compatible features
- MAJOR: incompatible API changes
"""
NONE = 0
PATCH = 1
MINOR = 2
MAJOR = 3
def __str__(self) -> str:
return self.name
@classmethod
def from_value(cls, value: object) -> VersionIncrement:
if not isinstance(value, str):
return VersionIncrement.NONE
try:
return cls[value]
except KeyError:
return VersionIncrement.NONE