Skip to content

Commit f111e56

Browse files
committed
cast
1 parent 3c6018d commit f111e56

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

src/opengeodeweb_viewer/rpc/mesh/points/mesh_points_protocols.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Standard library imports
22
import os
3+
from typing import cast
34

45
# Third party imports
56
from wslink import register as exportRpc
@@ -10,6 +11,7 @@
1011
validate_schema,
1112
RpcParams,
1213
RpcParamsWithColor,
14+
JsonValue,
1315
)
1416
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
1517

@@ -23,18 +25,24 @@ class VtkMeshPointsView(VtkMeshView):
2325
def __init__(self) -> None:
2426
super().__init__()
2527

26-
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["visibility"]["rpc"])
28+
@exportRpc(
29+
mesh_points_prefix + cast(str, mesh_points_schemas_dict["visibility"]["rpc"])
30+
)
2731
def setMeshPointsVisibility(self, params: RpcParams) -> None:
2832
validate_schema(
29-
params, self.mesh_points_schemas_dict["visibility"], self.mesh_points_prefix
33+
params,
34+
cast(dict[str, JsonValue], self.mesh_points_schemas_dict["visibility"]),
35+
self.mesh_points_prefix,
3036
)
3137
id, visibility = params["id"], params["visibility"]
3238
self.SetPointsVisibility(id, visibility)
3339

34-
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["color"]["rpc"])
40+
@exportRpc(mesh_points_prefix + cast(str, mesh_points_schemas_dict["color"]["rpc"]))
3541
def setMeshPointsColor(self, params: RpcParamsWithColor) -> None:
3642
validate_schema(
37-
params, self.mesh_points_schemas_dict["color"], self.mesh_points_prefix
43+
params,
44+
cast(dict[str, JsonValue], self.mesh_points_schemas_dict["color"]),
45+
self.mesh_points_prefix,
3846
)
3947
id, red, green, blue = (
4048
params["id"],
@@ -44,19 +52,26 @@ def setMeshPointsColor(self, params: RpcParamsWithColor) -> None:
4452
)
4553
self.SetPointsColor(id, red, green, blue)
4654

47-
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["size"]["rpc"])
55+
@exportRpc(mesh_points_prefix + cast(str, mesh_points_schemas_dict["size"]["rpc"]))
4856
def setMeshPointsSize(self, params: RpcParams) -> None:
4957
validate_schema(
50-
params, self.mesh_points_schemas_dict["size"], self.mesh_points_prefix
58+
params,
59+
cast(dict[str, JsonValue], self.mesh_points_schemas_dict["size"]),
60+
self.mesh_points_prefix,
5161
)
5262
id, size = params["id"], params["size"]
5363
self.SetPointsSize(id, size)
5464

55-
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["vertex_attribute"]["rpc"])
65+
@exportRpc(
66+
mesh_points_prefix
67+
+ cast(str, mesh_points_schemas_dict["vertex_attribute"]["rpc"])
68+
)
5669
def setMeshPointsVertexAttribute(self, params: RpcParams) -> None:
5770
validate_schema(
5871
params,
59-
self.mesh_points_schemas_dict["vertex_attribute"],
72+
cast(
73+
dict[str, JsonValue], self.mesh_points_schemas_dict["vertex_attribute"]
74+
),
6075
self.mesh_points_prefix,
6176
)
6277
id, name = params["id"], params["name"]

src/tests/mesh/points/test_mesh_points_protocols.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Standard library imports
2-
from typing import Callable
2+
from typing import Callable, cast
33

44
# Third party imports
55
from src.opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
@@ -20,7 +20,7 @@ def test_points_visibility(
2020

2121
server.call(
2222
VtkMeshPointsView.mesh_points_prefix
23-
+ VtkMeshPointsView.mesh_points_schemas_dict["visibility"]["rpc"],
23+
+ cast(str, VtkMeshPointsView.mesh_points_schemas_dict["visibility"]["rpc"]),
2424
[{"id": mesh_id, "visibility": True}],
2525
)
2626
assert server.compare_image(3, "mesh/points/visibility.jpeg") == True
@@ -34,7 +34,7 @@ def test_points_size(
3434

3535
server.call(
3636
VtkMeshPointsView.mesh_points_prefix
37-
+ VtkMeshPointsView.mesh_points_schemas_dict["size"]["rpc"],
37+
+ cast(str, VtkMeshPointsView.mesh_points_schemas_dict["size"]["rpc"]),
3838
[{"id": mesh_id, "size": 15}],
3939
)
4040
assert server.compare_image(3, "mesh/points/size.jpeg") == True
@@ -48,7 +48,7 @@ def test_points_color(
4848

4949
server.call(
5050
VtkMeshPointsView.mesh_points_prefix
51-
+ VtkMeshPointsView.mesh_points_schemas_dict["color"]["rpc"],
51+
+ cast(str, VtkMeshPointsView.mesh_points_schemas_dict["color"]["rpc"]),
5252
[{"id": mesh_id, "color": {"r": 255, "g": 0, "b": 0}}],
5353
)
5454
assert server.compare_image(3, "mesh/points/color.jpeg") == True
@@ -61,28 +61,29 @@ def test_points_with_point_set(
6161

6262
dataset_factory(id=mesh_id, viewable_file_name="points.vtp")
6363
server.call(
64-
VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"],
64+
VtkMeshView.mesh_prefix
65+
+ cast(str, VtkMeshView.mesh_schemas_dict["register"]["rpc"]),
6566
[{"id": mesh_id}],
6667
)
6768
assert server.compare_image(3, "mesh/points/register_point_set.jpeg") == True
6869

6970
server.call(
7071
VtkMeshPointsView.mesh_points_prefix
71-
+ VtkMeshPointsView.mesh_points_schemas_dict["size"]["rpc"],
72+
+ cast(str, VtkMeshPointsView.mesh_points_schemas_dict["size"]["rpc"]),
7273
[{"id": mesh_id, "size": 10}],
7374
)
7475
assert server.compare_image(3, "mesh/points/point_set_size.jpeg") == True
7576

7677
server.call(
7778
VtkMeshPointsView.mesh_points_prefix
78-
+ VtkMeshPointsView.mesh_points_schemas_dict["color"]["rpc"],
79+
+ cast(str, VtkMeshPointsView.mesh_points_schemas_dict["color"]["rpc"]),
7980
[{"id": mesh_id, "color": {"r": 255, "g": 0, "b": 0}}],
8081
)
8182
assert server.compare_image(3, "mesh/points/point_set_color.jpeg") == True
8283

8384
server.call(
8485
VtkMeshPointsView.mesh_points_prefix
85-
+ VtkMeshPointsView.mesh_points_schemas_dict["visibility"]["rpc"],
86+
+ cast(str, VtkMeshPointsView.mesh_points_schemas_dict["visibility"]["rpc"]),
8687
[{"id": mesh_id, "visibility": False}],
8788
)
8889
assert server.compare_image(3, "mesh/points/point_set_visibility.jpeg") == True

0 commit comments

Comments
 (0)