SIMNet/simnet/version.py

34 lines
883 B
Python
Raw Permalink Normal View History

2023-05-08 02:54:45 +00:00
from typing import NamedTuple
__all__ = ("__version__", "__version_info__")
class Version(NamedTuple):
"""Copies the behavior of sys.version_info. serial is always 0 for stable releases."""
major: int
minor: int
micro: int
release_level: str
serial: int
def _rl_shorthand(self) -> str: # skipcq: PY-D0003
return {
"alpha": "a",
"beta": "b",
"candidate": "rc",
}[self.release_level]
def __str__(self) -> str:
version = f"{self.major}.{self.minor}"
if self.micro != 0:
version = f"{version}.{self.micro}"
if self.release_level != "final":
version = f"{version}{self._rl_shorthand()}{self.serial}"
return version
2024-03-13 07:05:26 +00:00
__version_info__ = Version(major=0, minor=1, micro=21, release_level="beta", serial=0)
2023-05-08 02:54:45 +00:00
__version__ = str(__version_info__)