Skip to content

Commit 2c00abc

Browse files
Berik AshimovBerik Ashimov
authored andcommitted
Use importlib.metadata for __version__ to avoid drift
1 parent fde0e02 commit 2c00abc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/hawkapi/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from importlib.metadata import PackageNotFoundError, version
56
from typing import TYPE_CHECKING, Any
67

78
# Eager imports — core types used in every application
@@ -79,7 +80,10 @@
7980
from hawkapi.validation.constraints import Body, Cookie, Header, Path, Query
8081
from hawkapi.websocket import WebSocket, WebSocketDisconnect
8182

82-
__version__ = "0.1.7"
83+
try:
84+
__version__ = version("hawkapi")
85+
except PackageNotFoundError: # pragma: no cover - running from a source tree without install
86+
__version__ = "0.0.0"
8387

8488
# Lazy imports — loaded on first access for faster cold start
8589
_LAZY_IMPORTS: dict[str, tuple[str, str]] = {

0 commit comments

Comments
 (0)