Skip to content

Commit dd9ef78

Browse files
committed
Optional and union types replaced by python actual types
1 parent 9d58c30 commit dd9ef78

File tree

4 files changed

+19
-31
lines changed

4 files changed

+19
-31
lines changed

src/opengeodeweb_viewer/object/object_methods.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Standard library imports
22
import os
3-
from typing import Optional, Union
43

54
# Third party imports
65
import vtk
76

87
# Local application imports
9-
# from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
108
from opengeodeweb_viewer.vtk_protocol import VtkView
119

1210

@@ -19,7 +17,7 @@ def registerObject(
1917
id: str,
2018
file_name: str,
2119
reader: vtk.vtkDataReader,
22-
filter: Optional[vtk.vtkAlgorithm],
20+
filter: vtk.vtkAlgorithm | None,
2321
mapper: vtk.vtkMapper,
2422
) -> None:
2523
actor = vtk.vtkActor()

src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py

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

55
# Third party imports
66
import vtk
@@ -22,7 +22,7 @@ def __init__(self) -> None:
2222
super().__init__()
2323

2424
@exportRpc(mesh_prefix + mesh_schemas_dict["register"]["rpc"])
25-
def registerMesh(self, params: dict[str, Union[str, int, float, bool]]) -> None:
25+
def registerMesh(self, params: dict[str, str | int | float | bool]) -> None:
2626
validate_schema(params, self.mesh_schemas_dict["register"], self.mesh_prefix)
2727
data_id = str(params["id"])
2828
try:
@@ -75,34 +75,30 @@ def registerMesh(self, params: dict[str, Union[str, int, float, bool]]) -> None:
7575
raise
7676

7777
@exportRpc(mesh_prefix + mesh_schemas_dict["deregister"]["rpc"])
78-
def deregisterMesh(self, params: dict[str, Union[str, int, float, bool]]) -> None:
78+
def deregisterMesh(self, params: dict[str, str | int | float | bool]) -> None:
7979
validate_schema(params, self.mesh_schemas_dict["deregister"], self.mesh_prefix)
8080
data_id = str(params["id"])
8181
self.deregisterObject(data_id)
8282

8383
@exportRpc(mesh_prefix + mesh_schemas_dict["visibility"]["rpc"])
84-
def SetMeshVisibility(
85-
self, params: dict[str, Union[str, int, float, bool]]
86-
) -> None:
84+
def SetMeshVisibility(self, params: dict[str, str | int | float | bool]) -> None:
8785
validate_schema(params, self.mesh_schemas_dict["visibility"], self.mesh_prefix)
8886
data_id, visibility = str(params["id"]), bool(params["visibility"])
8987
self.SetVisibility(data_id, visibility)
9088

9189
@exportRpc(mesh_prefix + mesh_schemas_dict["opacity"]["rpc"])
92-
def setMeshOpacity(self, params: dict[str, Union[str, int, float, bool]]) -> None:
90+
def setMeshOpacity(self, params: dict[str, str | int | float | bool]) -> None:
9391
validate_schema(params, self.mesh_schemas_dict["opacity"], self.mesh_prefix)
9492
data_id, opacity = str(params["id"]), float(params["opacity"])
9593
self.SetOpacity(data_id, opacity)
9694

9795
@exportRpc(mesh_prefix + mesh_schemas_dict["color"]["rpc"])
9896
def setMeshColor(
9997
self,
100-
params: dict[
101-
str, Union[str, int, float, bool, dict[str, Union[str, int, float]]]
102-
],
98+
params: dict[str, str | int | float | bool | dict[str, str | int | float]],
10399
) -> None:
104100
validate_schema(params, self.mesh_schemas_dict["color"], self.mesh_prefix)
105-
color_dict = cast(dict[str, Union[str, int, float]], params["color"])
101+
color_dict = cast(dict[str, str | int | float], params["color"])
106102
data_id, red, green, blue = (
107103
str(params["id"]),
108104
int(color_dict["r"]),
@@ -112,9 +108,7 @@ def setMeshColor(
112108
self.SetColor(data_id, red, green, blue)
113109

114110
@exportRpc(mesh_prefix + mesh_schemas_dict["apply_textures"]["rpc"])
115-
def meshApplyTextures(
116-
self, params: dict[str, Union[str, list[dict[str, str]]]]
117-
) -> None:
111+
def meshApplyTextures(self, params: dict[str, str | list[dict[str, str]]]) -> None:
118112
validate_schema(
119113
params, self.mesh_schemas_dict["apply_textures"], self.mesh_prefix
120114
)

src/opengeodeweb_viewer/vtk_protocol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Standard library imports
22
import os
3-
from typing import Optional, Union
3+
from typing import Union
44

55
# Third party imports
66
import vtk
@@ -51,7 +51,7 @@ def get_data(self, data_id: str) -> dict[str, Union[str, list[str], None]]:
5151
print(f"Error fetching data {data_id}: {e}")
5252
raise
5353

54-
def get_data_file_path(self, data_id: str, filename: Optional[str] = None) -> str:
54+
def get_data_file_path(self, data_id: str, filename: str = None) -> str:
5555
if filename is None:
5656
data = self.get_data(data_id)
5757
viewable_file_name = data["viewable_file_name"]
@@ -83,7 +83,7 @@ def register_object(
8383
self,
8484
id: str,
8585
reader: vtk.vtkAlgorithm,
86-
filter: Optional[vtk.vtkAlgorithm],
86+
filter: vtk.vtkAlgorithm,
8787
actor: vtk.vtkActor,
8888
mapper: vtk.vtkMapper,
8989
textures: dict[str, Union[str, int, float]],

src/tests/conftest.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
from pathlib import Path
1212
import xml.etree.ElementTree as ET
13-
from typing import Callable, Optional, Union, Generator
13+
from typing import Callable, Generator
1414
from opengeodeweb_viewer import config
1515
from opengeodeweb_microservice.database.connection import get_session, init_database
1616
from opengeodeweb_microservice.database.data import Data
@@ -34,14 +34,10 @@ def __init__(self, log: str) -> None:
3434
def call(
3535
self,
3636
rpc: str,
37-
params: Optional[
38-
list[
39-
Union[
40-
dict[str, Union[str, int, float, bool, dict[str, int], list[str]]],
41-
int,
42-
]
43-
]
44-
] = None,
37+
params: (
38+
list[dict[str, str | int | float | bool | dict[str, int] | list[str]] | int]
39+
| None
40+
) = None,
4541
) -> None:
4642
if params is None:
4743
params = [{}]
@@ -65,7 +61,7 @@ def print_log(self) -> None:
6561
output += line
6662
print(output)
6763

68-
def get_response(self) -> Union[bytes, dict[str, object], str]:
64+
def get_response(self) -> bytes | dict[str, object] | str:
6965
response = self.ws.recv()
7066
if isinstance(response, bytes):
7167
return response
@@ -217,7 +213,7 @@ def configure_test_environment() -> Generator[None, None, None]:
217213
@pytest.fixture
218214
def dataset_factory() -> Callable[..., str]:
219215
def create_dataset(
220-
*, id: str, viewable_file_name: str, geode_object: Optional[str] = None
216+
*, id: str, viewable_file_name: str, geode_object: str | None = None
221217
) -> str:
222218
session = get_session()
223219
if geode_object is None:

0 commit comments

Comments
 (0)