Skip to content

Commit e573792

Browse files
authored
Merge branch 'main' into v1.5535.0
2 parents 5ac8957 + 451d1ba commit e573792

File tree

8 files changed

+51
-7
lines changed

8 files changed

+51
-7
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install dependencies and library
3232
run: poetry install
3333
- name: Check format
34-
run: poetry run ruff format -q
34+
run: poetry run ruff format --check
3535

3636
typing:
3737
runs-on: ubuntu-latest

scaleway-async/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ mypy = "^1.5.1"
3535
requires = ["poetry-core"]
3636
build-backend = "poetry.core.masonry.api"
3737

38-
[tool.ruff]
38+
[tool.ruff.lint]
3939
ignore = ["E501"]

scaleway-core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ mypy = "^1.5.1"
3737
requires = ["poetry-core"]
3838
build-backend = "poetry.core.masonry.api"
3939

40-
[tool.ruff]
40+
[tool.ruff.lint]
4141
ignore = ["E501"]

scaleway-core/scaleway_core/bridge/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
from .timeseries import unmarshal_TimeSeriesPoint
2323
from .timeseries import marshal_TimeSeriesPoint
2424

25+
from .decimal import unmarshal_Decimal
26+
from .decimal import marshal_Decimal
27+
2528
__all__ = [
2629
"Money",
2730
"unmarshal_Money",
@@ -42,4 +45,6 @@
4245
"marshal_TimeSeries",
4346
"unmarshal_TimeSeriesPoint",
4447
"marshal_TimeSeriesPoint",
48+
"unmarshal_Decimal",
49+
"marshal_Decimal",
4550
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from decimal import Decimal
2+
from typing import Any, Dict
3+
4+
5+
def unmarshal_Decimal(data: Any) -> Decimal:
6+
"""
7+
Unmarshal an instance of Decimal from the given data.
8+
"""
9+
if not isinstance(data, dict):
10+
raise TypeError(
11+
"Unmarshalling the type 'Decimal' failed as data isn't a dictionary."
12+
)
13+
14+
if "value" not in data:
15+
raise TypeError(
16+
"Unmarshalling the type 'Decimal' failed as data does not contain a 'value' key."
17+
)
18+
19+
return Decimal(data["value"])
20+
21+
22+
def marshal_Decimal(data: Decimal) -> Dict[str, Any]:
23+
"""
24+
Marshal an instance of Decimal into google.protobuf.Decimal JSON representation.
25+
"""
26+
return {
27+
"value": str(data),
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
from decimal import Decimal
3+
4+
from scaleway_core.bridge import unmarshal_Decimal, marshal_Decimal
5+
6+
7+
class TestBridgeMarshal(unittest.TestCase):
8+
def test_decimal_marshal(self):
9+
decimal = Decimal("1.2")
10+
self.assertEqual(marshal_Decimal(decimal), {"value": "1.2"})
11+
12+
def test_decimal_unmarshal(self):
13+
decimal = Decimal("1.2")
14+
self.assertEqual(unmarshal_Decimal({"value": "1.2"}), decimal)

scaleway/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ mypy = "^1.5.1"
3535
requires = ["poetry-core"]
3636
build-backend = "poetry.core.masonry.api"
3737

38-
[tool.ruff]
38+
[tool.ruff.lint]
3939
ignore = ["E501"]

scaleway/tests/test_total_count_legacy.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111

1212

1313
class TestTotalCountLegacy(unittest.TestCase):
14-
1514
def setUp(self) -> None:
1615
self.client = Client()
1716
self.instance_api = InstanceV1API(self.client, bypass_validation=True)
1817

1918
def test_list_servers_type(self):
2019
list_server_type = self.instance_api.list_servers_types(zone="fr-par-1")
2120
self.assertIsNotNone(list_server_type.total_count)
22-
23-

0 commit comments

Comments
 (0)