Skip to content

Commit a8d4664

Browse files
authored
fix(core): make the marshal function signature consistent (#1326)
1 parent 55b4476 commit a8d4664

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

scaleway-core/scaleway_core/bridge/decimal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from decimal import Decimal
22
from typing import Any, Dict
33

4+
from scaleway_core.profile import ProfileDefaults
5+
46

57
def unmarshal_Decimal(data: Any) -> Decimal:
68
"""
@@ -19,7 +21,7 @@ def unmarshal_Decimal(data: Any) -> Decimal:
1921
return Decimal(data["value"])
2022

2123

22-
def marshal_Decimal(data: Decimal) -> Dict[str, Any]:
24+
def marshal_Decimal(data: Decimal, _defaults: ProfileDefaults | None) -> Dict[str, Any]:
2325
"""
2426
Marshal an instance of Decimal into google.protobuf.Decimal JSON representation.
2527
"""

scaleway-core/scaleway_core/bridge/money.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from dataclasses import dataclass
22
from typing import Any, Dict
33

4+
from scaleway_core.profile import ProfileDefaults
5+
46

57
@dataclass
68
class Money:
@@ -48,7 +50,7 @@ def unmarshal_Money(data: Any) -> Money:
4850
)
4951

5052

51-
def marshal_Money(data: Money) -> Dict[str, Any]:
53+
def marshal_Money(data: Money, _defaults: ProfileDefaults | None) -> Dict[str, Any]:
5254
"""
5355
Marshal an instance of Money into a JSON compatible data structure.
5456
"""

scaleway-core/scaleway_core/bridge/scwfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from dataclasses import dataclass
22
from typing import Any, Dict
33

4+
from scaleway_core.profile import ProfileDefaults
5+
46

57
@dataclass
68
class ScwFile:
@@ -40,7 +42,7 @@ def unmarshal_ScwFile(data: Any) -> ScwFile:
4042
)
4143

4244

43-
def marshal_ScwFile(obj: ScwFile) -> Dict[str, Any]:
45+
def marshal_ScwFile(obj: ScwFile, _defaults: ProfileDefaults | None) -> Dict[str, Any]:
4446
"""
4547
Marshals a ScwFile object into a dict.
4648
"""

scaleway-core/scaleway_core/bridge/serviceinfo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from dataclasses import dataclass
22
from typing import Any, Dict, Optional
33

4+
from scaleway_core.profile import ProfileDefaults
5+
46

57
@dataclass
68
class ServiceInfo:
@@ -48,7 +50,9 @@ def unmarshal_ServiceInfo(data: Any) -> ServiceInfo:
4850
)
4951

5052

51-
def marshal_ServiceInfo(obj: ServiceInfo) -> Dict[str, Any]:
53+
def marshal_ServiceInfo(
54+
obj: ServiceInfo, _defaults: ProfileDefaults | None
55+
) -> Dict[str, Any]:
5256
"""
5357
Marshals a ServiceInfo object into a dict.
5458
"""

scaleway-core/scaleway_core/bridge/timeseries.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from typing import Any, Dict, List
44
from dateutil import parser
55

6+
from scaleway_core.profile import ProfileDefaults
7+
68

79
@dataclass
810
class TimeSeriesPoint:
@@ -36,7 +38,9 @@ def unmarshal_TimeSeriesPoint(data: Any) -> TimeSeriesPoint:
3638
)
3739

3840

39-
def marshal_TimeSeriesPoint(data: TimeSeriesPoint) -> Dict[str, Any]:
41+
def marshal_TimeSeriesPoint(
42+
data: TimeSeriesPoint, _defaults: ProfileDefaults | None
43+
) -> Dict[str, Any]:
4044
"""
4145
Marshal an instance of TimeSeriesPoint into a JSON compatible data structure.
4246
"""
@@ -84,12 +88,14 @@ def unmarshal_TimeSeries(data: Any) -> TimeSeries:
8488
)
8589

8690

87-
def marshal_TimeSeries(data: TimeSeries) -> Dict[str, Any]:
91+
def marshal_TimeSeries(
92+
data: TimeSeries, defaults: ProfileDefaults | None
93+
) -> Dict[str, Any]:
8894
"""
8995
Marshal an instance of TimeSeries into a JSON compatible data structure.
9096
"""
9197
return {
9298
"name": data.name,
93-
"points": [marshal_TimeSeriesPoint(point) for point in data.points],
99+
"points": [marshal_TimeSeriesPoint(point, defaults) for point in data.points],
94100
"metadata": data.metadata,
95101
}

scaleway-core/tests/test_bridge_marshal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class TestBridgeMarshal(unittest.TestCase):
88
def test_decimal_marshal(self):
99
decimal = Decimal("1.2")
10-
self.assertEqual(marshal_Decimal(decimal), {"value": "1.2"})
10+
self.assertEqual(marshal_Decimal(decimal, None), {"value": "1.2"})
1111

1212
def test_decimal_unmarshal(self):
1313
decimal = Decimal("1.2")

0 commit comments

Comments
 (0)