Extract version function to Version class
+from plextraktsync.decorators.cached_property import cached_property
+
+
+class Version:
+ @cached_property
+ def version(self):
+ from plextraktsync import __version__
+
+ # Released in PyPI
+ if not __version__.endswith(".0dev0"):
+ return __version__
+
+ gv = git_version_info()
+ if gv:
+ return f"{__version__}: {gv}"
+
+ return __version__
+
+
def git_version_info():
try:
from gitinfo import get_git_info
@@ -13,15 +32,8 @@ def git_version_info():
return f"{commit['commit'][0:8]}: {message} @{commit['author_date']}"
-def version():
- from plextraktsync import __version__
+VERSION = Version()
- # Released in PyPI
- if not __version__.endswith(".0dev0"):
- return __version__
- gv = git_version_info()
- if gv:
- return f"{__version__}: {gv}"
-
- return __version__
+def version():
+ return VERSION.version
