Skip to content

Instantly share code, notes, and snippets.

@jonafato
Last active May 6, 2025 17:03
Show Gist options
  • Save jonafato/6f8d18582007d1c9e94d9dd185d8f83a to your computer and use it in GitHub Desktop.
Save jonafato/6f8d18582007d1c9e94d9dd185d8f83a to your computer and use it in GitHub Desktop.
version_info
import math
import sys
from typing import NamedTuple
# Copy the helper class from the Doc directory to represent a createable version_info class
# https://github.com/python/cpython/blob/3dfed230928de0f649061782a36691066a0ef058/Doc/tools/extensions/patchlevel.py#L25-L30
class version_info(NamedTuple): # noqa: N801
major: int #: Major release number
minor: int #: Minor release number
micro: int #: Patch release number
releaselevel: Literal["alpha", "beta", "candidate", "final"]
serial: int #: Serial release number
sys.version_info = version_info(*str(math.pi).split('.'), *sys.version_info[2:])
# sys.version_info is now version_info(major='3', minor='141592653589793', micro=0, releaselevel='alpha', serial=6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment