fix: better version fetch

This commit is contained in:
Alex
2026-04-21 14:07:26 +01:00
parent 76d8f49ccb
commit 619b41dc5b
2 changed files with 4 additions and 29 deletions

View File

@@ -1 +0,0 @@
0.16.1

View File

@@ -1,34 +1,10 @@
"""DocsGPT backend version string.
Read from the top-level ``VERSION`` file so release tooling can bump the
version without touching Python code. Cached after first read.
"""
"""DocsGPT backend version string."""
from __future__ import annotations
from pathlib import Path
from typing import Optional
_UNKNOWN = "unknown"
_VERSION_PATH = Path(__file__).resolve().parent.parent / "VERSION"
_cached: Optional[str] = None
__version__ = "0.16.1"
def get_version() -> str:
"""Return the DocsGPT backend version, or ``"unknown"`` if absent.
A missing ``VERSION`` file is treated as a soft failure — callers
(notably the startup version check) must never crash because the
file wasn't shipped with the source checkout.
"""
global _cached
if _cached is not None:
return _cached
try:
_cached = _VERSION_PATH.read_text(encoding="utf-8").strip() or _UNKNOWN
except (FileNotFoundError, OSError):
_cached = _UNKNOWN
return _cached
__version__ = get_version()
"""Return the DocsGPT backend version."""
return __version__