Skip to content

Commit 682b821

Browse files
committed
fix: only add version if not none
1 parent 84cba3c commit 682b821

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clients/algoliasearch-client-python/algoliasearch/http/user_agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def __init__(self) -> None:
1919
def get(self) -> str:
2020
return self.value
2121

22-
def add(self, segment: str, version: Optional[str] = __version__) -> Self:
23-
self.value += "; {} ({})".format(segment, version or __version__)
22+
def add(self, segment: str, version: Optional[str] = None) -> Self:
23+
self.value += "; {}".format(segment)
24+
25+
if version is not None:
26+
self.value += " ({})".format(version)
27+
2428
return self

playground/python/app/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def main():
1313
client = SearchClientSync(
1414
environ.get("ALGOLIA_APPLICATION_ID"), environ.get("ALGOLIA_ADMIN_KEY")
1515
)
16-
client.add_user_agent("playground", None)
16+
client.add_user_agent("playground", "Foo")
1717

1818
print("user_agent", client._config._user_agent.get())
1919
print("client initialized", client)

0 commit comments

Comments
 (0)