Skip to content

Commit 2fed099

Browse files
authored
Remove version from User-Agent header (#211)
1 parent bca7f1a commit 2fed099

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

src/tomtom_apis/api.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import socket
77
import uuid
88
from dataclasses import dataclass, field
9-
from importlib import metadata
109
from types import TracebackType
1110
from typing import Any, Self
1211

@@ -217,14 +216,6 @@ def __init__(
217216
self.options = options
218217
self.session = ClientSession(options.base_url, timeout=options.timeout) if session is None else session
219218
self._close_session = session is None
220-
self._version: str | None = None
221-
222-
@property
223-
def version(self) -> str:
224-
"""Get the version of the TomTom API client."""
225-
if self._version is None:
226-
self._version = metadata.version(__package__)
227-
return self._version
228219

229220
async def _request( # pylint: disable=too-many-arguments
230221
self: Self,
@@ -339,7 +330,7 @@ def _prepare_headers(self: Self, headers: dict[str, str] | None, options: ApiOpt
339330
"""
340331
merged_headers = {
341332
CONTENT_TYPE: "application/json",
342-
USER_AGENT: f"TomTomApiPython/{self.version}",
333+
USER_AGENT: "python/tomtom_apis",
343334
**(headers or {}),
344335
}
345336

tests/test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async def test_get_request(base_api: BaseApi, mock_session: AsyncMock) -> None:
137137
json=None,
138138
headers={
139139
"Content-Type": "application/json",
140-
"User-Agent": f"TomTomApiPython/{base_api.version}",
140+
"User-Agent": "python/tomtom_apis",
141141
},
142142
)
143143
assert isinstance(response, Response)
@@ -157,7 +157,7 @@ async def test_get_request_with_gzip(base_api: BaseApi, mock_session: AsyncMock)
157157
json=None,
158158
headers={
159159
"Content-Type": "application/json",
160-
"User-Agent": f"TomTomApiPython/{base_api.version}",
160+
"User-Agent": "python/tomtom_apis",
161161
"Accept-Encoding": "gzip",
162162
},
163163
)
@@ -178,7 +178,7 @@ async def test_post_request(base_api: BaseApi, mock_session: AsyncMock) -> None:
178178
json=data.to_dict(),
179179
headers={
180180
"Content-Type": "application/json",
181-
"User-Agent": f"TomTomApiPython/{base_api.version}",
181+
"User-Agent": "python/tomtom_apis",
182182
},
183183
)
184184
assert isinstance(response, Response)
@@ -197,7 +197,7 @@ async def test_delete_request(base_api: BaseApi, mock_session: AsyncMock) -> Non
197197
json=None,
198198
headers={
199199
"Content-Type": "application/json",
200-
"User-Agent": f"TomTomApiPython/{base_api.version}",
200+
"User-Agent": "python/tomtom_apis",
201201
},
202202
)
203203
assert isinstance(response, Response)
@@ -217,7 +217,7 @@ async def test_put_request(base_api: BaseApi, mock_session: AsyncMock) -> None:
217217
json=data.to_dict(),
218218
headers={
219219
"Content-Type": "application/json",
220-
"User-Agent": f"TomTomApiPython/{base_api.version}",
220+
"User-Agent": "python/tomtom_apis",
221221
},
222222
)
223223
assert isinstance(response, Response)

0 commit comments

Comments
 (0)