Skip to content

Commit bb78fc2

Browse files
committed
Use importlib.metadata.version() for __version__
Replace hardcoded __VERSION__ = "0.1.9" in client.py with importlib.metadata.version() sourced from pyproject.toml. This fixes version drift (pyproject.toml had 0.1.10) and establishes a single source of truth for the package version. Closes #29
1 parent 50cf840 commit bb78fc2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

leakix/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from leakix.client import __VERSION__ as __VERSION__
1+
from importlib.metadata import version
2+
23
from leakix.client import Client as Client
34
from leakix.client import HostResult as HostResult
45
from leakix.client import Scope as Scope
@@ -68,8 +69,10 @@
6869
SuccessResponse as SuccessResponse,
6970
)
7071

72+
__version__ = version("leakix")
73+
7174
__all__ = [
72-
"__VERSION__",
75+
"__version__",
7376
"Client",
7477
"HostResult",
7578
"Scope",

leakix/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from enum import Enum
3+
from importlib.metadata import version
34

45
import requests
56
from l9format import l9format
@@ -10,8 +11,6 @@
1011
from leakix.query import EmptyQuery, Query
1112
from leakix.response import ErrorResponse, RateLimitResponse, SuccessResponse
1213

13-
__VERSION__ = "0.1.9"
14-
1514

1615
class Scope(Enum):
1716
SERVICE = "service"
@@ -38,7 +37,7 @@ def __init__(
3837
self.base_url = base_url if base_url else DEFAULT_URL
3938
self.headers = {
4039
"Accept": "application/json",
41-
"User-agent": f"leakix-client-python/{__VERSION__}",
40+
"User-agent": f"leakix-client-python/{version('leakix')}",
4241
}
4342
if api_key:
4443
self.headers["api-key"] = api_key

0 commit comments

Comments
 (0)