Skip to content

Commit 1a468d0

Browse files
authored
Even better optional Infinity version handling (#323)
* Return None instead of Undefined * make print a warn * makr warning a string * update test too
1 parent b9c8d9f commit 1a468d0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

python/pdstools/infinity/internal/_base_client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import logging
44
import os
5+
import warnings
56
from typing import (
67
TYPE_CHECKING,
78
Any,
@@ -107,12 +108,12 @@ def _get_version(self, repo):
107108
elif "repository_type" in repo:
108109
return "24.2"
109110
else:
110-
print(
111-
"Could not infer Pega version automatically. ",
112-
"For full compatibility, please supply the pega_version argument",
113-
"to the Infinity class.",
111+
warnings.warn(
112+
"""Could not infer Pega version automatically.
113+
For full compatibility, please supply the pega_version argument to the Infinity class.
114+
""",
114115
)
115-
return "Undefined"
116+
return None
116117

117118
@classmethod
118119
def from_client_id_and_secret(

python/tests/test_apis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_base_client(httpx_mock: HTTPXMock, monkeypatch):
5353
assert client.pega_version is None
5454
assert client._get_version({"repository_name": "Repo"}) == "24.1"
5555
assert client._get_version({"repository_type": "AWS"}) == "24.2"
56-
assert client._get_version({"Pega Version": "Undefined"}) == "Undefined"
56+
assert client._get_version({"Pega Version": "Undefined"}) is None
5757

5858
with pytest.raises(ValueError):
5959
_base_client.BaseClient.from_basic_auth()

0 commit comments

Comments
 (0)