Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit 0e340ed

Browse files
committed
Fix the method overloading issues in python
1 parent 0612d8d commit 0e340ed

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

python/selfie-lib/selfie_lib/Snapshot.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ def __str__(self):
5151
return f"[{self._subject} {self._facet_data}]"
5252

5353
@staticmethod
54-
def of(binary):
55-
return Snapshot(SnapshotValue.of(binary), {})
56-
57-
@staticmethod
58-
def of(string):
59-
return Snapshot(SnapshotValue.of(string), {})
54+
def of(data):
55+
if isinstance(data, bytes):
56+
# Handling binary data
57+
return Snapshot(SnapshotValue.of(data), {})
58+
elif isinstance(data, str):
59+
# Handling string data
60+
return Snapshot(SnapshotValue.of(data), {})
61+
else:
62+
raise TypeError("Data must be either binary or string")
6063

6164
@staticmethod
6265
def of_entries(entries):

python/selfie-lib/selfie_lib/SnapshotValue.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ def value_string(self) -> str:
2020
pass
2121

2222
@staticmethod
23-
def of(value: Union[bytes, str]) -> "SnapshotValue":
24-
if isinstance(value, bytes):
25-
return SnapshotValueBinary(value)
26-
elif isinstance(value, str):
27-
return SnapshotValueString(unix_newlines(value))
23+
def of(cls, data):
24+
if isinstance(data, bytes):
25+
return cls(SnapshotValue.of(data), {})
26+
elif isinstance(data, str):
27+
return cls(SnapshotValue.of(data), {})
28+
elif isinstance(data, SnapshotValue):
29+
return cls(data, {})
2830
else:
29-
raise TypeError("Value must be either bytes or str")
31+
raise TypeError("Unsupported type for Snapshot creation")
3032

3133

3234
class SnapshotValueBinary(SnapshotValue):

0 commit comments

Comments
 (0)