[docs]@uniqueclassLevelBump(IntEnum):""" IntEnum representing valid types of bumps for a version. We use an IntEnum to enable ordering of levels. """NO_RELEASE=0PRERELEASE_REVISION=1PATCH=2MINOR=3MAJOR=4def__str__(self)->str:""" Return the level name rather than 'LevelBump.<level>' E.g. >>> str(LevelBump.NO_RELEASE) 'no_release' >>> str(LevelBump.MAJOR) 'major' """returnself.name.lower()
[docs]@classmethoddeffrom_string(cls,val:str)->LevelBump:""" Get the level from string representation. For backwards-compatibility, dashes are replaced with underscores so that: >>> LevelBump.from_string("no-release") == LevelBump.NO_RELEASE Equally, >>> LevelBump.from_string("minor") == LevelBump.MINOR """returncls[val.upper().replace("-","_")]