MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / from_value

Method from_value

commitizen/version_increment.py:50–63  ·  view source on GitHub ↗

Convert external increment input into a known increment. This lenient path is used for inputs such as CLI arguments where an unknown string should behave like "no increment" instead of raising. Matched ``bump_map`` values are validated separately so custom rules keep

(cls, value: object)

Source from the content-addressed store, hash-verified

48
49 @classmethod
50 def from_value(cls, value: object) -> VersionIncrement:
51 """Convert external increment input into a known increment.
52
53 This lenient path is used for inputs such as CLI arguments where an
54 unknown string should behave like "no increment" instead of raising.
55 Matched ``bump_map`` values are validated separately so custom rules keep
56 their historical fail-fast behavior.
57 """
58 if not isinstance(value, str):
59 return VersionIncrement.NONE
60 try:
61 return cls[value]
62 except KeyError:
63 return VersionIncrement.NONE
64
65 @classmethod
66 def _compile_pattern(cls, regex: RegexPattern) -> re.Pattern[str]:

Callers 2

__call__Method · 0.80

Calls

no outgoing calls

Tested by 1