bumpversion.autocast
Automatically detect the true Python type of a string and cast it to the correct type.
Based on https://github.com/cgreer/cgAutoCast/blob/master/cgAutoCast.py
Only used by Legacy configuration file parser.
boolify
python
def boolify(s: str) -> boolConvert a string to a boolean.
noneify
python
def noneify(s: str) -> NoneConvert a string to None.
listify
python
def listify(s: str) -> listConvert a string representation of a list into a list of homogeneous basic types.
The type of the elements in the list is determined via the first element. Successive elements are cast to that type.
Parameters
s: String representation of a list.
Returns
- List of homogeneous basic types.
Raises
ValueError: If string does not represent a list.TypeError: If string does not represent a list of homogeneous basic types.
autocast_value
python
def autocast_value(var: Any) -> AnyGuess the string representation of the variable's type.
Parameters
var: Value to autocast.
Returns
- The autocasted value.