Skip to content

Commit 1ab1624

Browse files
committed
type geode_objects
1 parent 1ed5fa7 commit 1ab1624

28 files changed

Lines changed: 513 additions & 251 deletions

mypy.ini

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
[mypy]
22
strict = True
33
files = src/
4-
disallow_untyped_decorators = False
4+
disallow_untyped_decorators = False
5+
6+
[mypy-opengeode.*]
7+
ignore_missing_imports = True
8+
9+
[mypy-opengeode_geosciences.*]
10+
ignore_missing_imports = True
11+
12+
[mypy-opengeode_inspector.*]
13+
ignore_missing_imports = True
14+
15+
[mypy-opengeode_io.*]
16+
ignore_missing_imports = True
17+
18+
[mypy-opengeode_geosciencesio.*]
19+
ignore_missing_imports = True
20+
21+
[mypy-geode_viewables.*]
22+
ignore_missing_imports = True
23+
24+
[mypy-werkzeug.*]
25+
ignore_missing_imports = True
26+
27+
[mypy-flask.*]
28+
ignore_missing_imports = True
29+
30+
[mypy-opengeodeweb_microservice.*]
31+
ignore_missing_imports = True
32+
33+
[mypy-dataclasses_json.*]
34+
ignore_missing_imports = True

src/opengeodeweb_back/geode_objects/geode_brep.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Standard library imports
22
from __future__ import annotations
3+
from typing import cast, Any
34

45
# Third party imports
56
import opengeode as og
@@ -24,7 +25,7 @@ def geode_object_type(cls) -> GeodeModelType:
2425
return "BRep"
2526

2627
def native_extension(self) -> str:
27-
return self.brep.native_extension()
28+
return cast(str, self.brep.native_extension())
2829

2930
@classmethod
3031
def is_3D(cls) -> bool:
@@ -51,30 +52,35 @@ def is_loadable(cls, filename: str) -> og.Percentage:
5152

5253
@classmethod
5354
def input_extensions(cls) -> list[str]:
54-
return og.BRepInputFactory.list_creators()
55+
return cast(list[str], og.BRepInputFactory.list_creators())
5556

5657
@classmethod
5758
def output_extensions(cls) -> list[str]:
58-
return og.BRepOutputFactory.list_creators()
59+
return cast(list[str], og.BRepOutputFactory.list_creators())
5960

6061
@classmethod
6162
def object_priority(cls, filename: str) -> int:
62-
return og.brep_object_priority(filename)
63+
return cast(int, og.brep_object_priority(filename))
6364

6465
def is_saveable(self, filename: str) -> bool:
65-
return og.is_brep_saveable(self.brep, filename)
66+
return cast(bool, og.is_brep_saveable(self.brep, filename))
6667

6768
def save(self, filename: str) -> list[str]:
68-
return og.save_brep(self.brep, filename)
69+
return cast(list[str], og.save_brep(self.brep, filename))
6970

7071
def save_viewable(self, filename_without_extension: str) -> str:
71-
return viewables.save_viewable_brep(self.brep, filename_without_extension)
72+
return cast(
73+
str, viewables.save_viewable_brep(self.brep, filename_without_extension)
74+
)
7275

7376
def save_light_viewable(self, filename_without_extension: str) -> str:
74-
return viewables.save_light_viewable_brep(self.brep, filename_without_extension)
77+
return cast(
78+
str,
79+
viewables.save_light_viewable_brep(self.brep, filename_without_extension),
80+
)
7581

7682
def mesh_components(self) -> ComponentRegistry:
77-
return self.brep.mesh_components()
83+
return cast(dict[Any, list[Any]], self.brep.mesh_components())
7884

7985
def inspect(self) -> og_inspector.BRepInspectionResult:
8086
return og_inspector.inspect_brep(self.brep)

src/opengeodeweb_back/geode_objects/geode_cross_section.py

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

45
# Third party imports
56
import opengeode as og
@@ -29,7 +30,7 @@ def geode_object_type(cls) -> GeodeModelType:
2930
return "CrossSection"
3031

3132
def native_extension(self) -> str:
32-
return self.cross_section.native_extension()
33+
return cast(str, self.cross_section.native_extension())
3334

3435
def builder(self) -> og_geosciences.CrossSectionBuilder:
3536
return og_geosciences.CrossSectionBuilder(self.cross_section)
@@ -48,28 +49,38 @@ def is_loadable(cls, filename: str) -> og.Percentage:
4849

4950
@classmethod
5051
def input_extensions(cls) -> list[str]:
51-
return og_geosciences.CrossSectionInputFactory.list_creators()
52+
return cast(list[str], og_geosciences.CrossSectionInputFactory.list_creators())
5253

5354
@classmethod
5455
def output_extensions(cls) -> list[str]:
55-
return og_geosciences.CrossSectionOutputFactory.list_creators()
56+
return cast(list[str], og_geosciences.CrossSectionOutputFactory.list_creators())
5657

5758
@classmethod
5859
def object_priority(cls, filename: str) -> int:
59-
return og_geosciences.cross_section_object_priority(filename)
60+
return cast(int, og_geosciences.cross_section_object_priority(filename))
6061

6162
def is_saveable(self, filename: str) -> bool:
62-
return og_geosciences.is_cross_section_saveable(self.cross_section, filename)
63+
return cast(
64+
bool, og_geosciences.is_cross_section_saveable(self.cross_section, filename)
65+
)
6366

6467
def save(self, filename: str) -> list[str]:
65-
return og_geosciences.save_cross_section(self.cross_section, filename)
68+
return cast(
69+
list[str], og_geosciences.save_cross_section(self.cross_section, filename)
70+
)
6671

6772
def save_viewable(self, filename_without_extension: str) -> str:
68-
return viewables.save_viewable_cross_section(
69-
self.cross_section, filename_without_extension
73+
return cast(
74+
str,
75+
viewables.save_viewable_cross_section(
76+
self.cross_section, filename_without_extension
77+
),
7078
)
7179

7280
def save_light_viewable(self, filename_without_extension: str) -> str:
73-
return viewables.save_light_viewable_cross_section(
74-
self.cross_section, filename_without_extension
81+
return cast(
82+
str,
83+
viewables.save_light_viewable_cross_section(
84+
self.cross_section, filename_without_extension
85+
),
7586
)

src/opengeodeweb_back/geode_objects/geode_edged_curve2d.py

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

45
# Third party imports
56
import opengeode as og
@@ -26,7 +27,7 @@ def geode_object_type(cls) -> GeodeMeshType:
2627
return "EdgedCurve2D"
2728

2829
def native_extension(self) -> str:
29-
return self.edged_curve.native_extension()
30+
return cast(str, self.edged_curve.native_extension())
3031

3132
@classmethod
3233
def is_3D(cls) -> bool:
@@ -53,30 +54,36 @@ def is_loadable(cls, filename: str) -> og.Percentage:
5354

5455
@classmethod
5556
def input_extensions(cls) -> list[str]:
56-
return og.EdgedCurveInputFactory2D.list_creators()
57+
return cast(list[str], og.EdgedCurveInputFactory2D.list_creators())
5758

5859
@classmethod
5960
def output_extensions(cls) -> list[str]:
60-
return og.EdgedCurveOutputFactory2D.list_creators()
61+
return cast(list[str], og.EdgedCurveOutputFactory2D.list_creators())
6162

6263
@classmethod
6364
def object_priority(cls, filename: str) -> int:
64-
return og.edged_curve_object_priority2D(filename)
65+
return cast(int, og.edged_curve_object_priority2D(filename))
6566

6667
def is_saveable(self, filename: str) -> bool:
67-
return og.is_edged_curve_saveable2D(self.edged_curve, filename)
68+
return cast(bool, og.is_edged_curve_saveable2D(self.edged_curve, filename))
6869

6970
def save(self, filename: str) -> list[str]:
70-
return og.save_edged_curve2D(self.edged_curve, filename)
71+
return cast(list[str], og.save_edged_curve2D(self.edged_curve, filename))
7172

7273
def save_viewable(self, filename_without_extension: str) -> str:
73-
return viewables.save_viewable_edged_curve2D(
74-
self.edged_curve, filename_without_extension
74+
return cast(
75+
str,
76+
viewables.save_viewable_edged_curve2D(
77+
self.edged_curve, filename_without_extension
78+
),
7579
)
7680

7781
def save_light_viewable(self, filename_without_extension: str) -> str:
78-
return viewables.save_light_viewable_edged_curve2D(
79-
self.edged_curve, filename_without_extension
82+
return cast(
83+
str,
84+
viewables.save_light_viewable_edged_curve2D(
85+
self.edged_curve, filename_without_extension
86+
),
8087
)
8188

8289
def inspect(self) -> og_inspector.EdgedCurveInspectionResult:

src/opengeodeweb_back/geode_objects/geode_edged_curve3d.py

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

45
# Third party imports
56
import opengeode as og
@@ -26,7 +27,7 @@ def geode_object_type(cls) -> GeodeMeshType:
2627
return "EdgedCurve3D"
2728

2829
def native_extension(self) -> str:
29-
return self.edged_curve.native_extension()
30+
return cast(str, self.edged_curve.native_extension())
3031

3132
@classmethod
3233
def is_3D(cls) -> bool:
@@ -53,30 +54,36 @@ def is_loadable(cls, filename: str) -> og.Percentage:
5354

5455
@classmethod
5556
def input_extensions(cls) -> list[str]:
56-
return og.EdgedCurveInputFactory3D.list_creators()
57+
return cast(list[str], og.EdgedCurveInputFactory3D.list_creators())
5758

5859
@classmethod
5960
def output_extensions(cls) -> list[str]:
60-
return og.EdgedCurveOutputFactory3D.list_creators()
61+
return cast(list[str], og.EdgedCurveOutputFactory3D.list_creators())
6162

6263
@classmethod
6364
def object_priority(cls, filename: str) -> int:
64-
return og.edged_curve_object_priority3D(filename)
65+
return cast(int, og.edged_curve_object_priority3D(filename))
6566

6667
def is_saveable(self, filename: str) -> bool:
67-
return og.is_edged_curve_saveable3D(self.edged_curve, filename)
68+
return cast(bool, og.is_edged_curve_saveable3D(self.edged_curve, filename))
6869

6970
def save(self, filename: str) -> list[str]:
70-
return og.save_edged_curve3D(self.edged_curve, filename)
71+
return cast(list[str], og.save_edged_curve3D(self.edged_curve, filename))
7172

7273
def save_viewable(self, filename_without_extension: str) -> str:
73-
return viewables.save_viewable_edged_curve3D(
74-
self.edged_curve, filename_without_extension
74+
return cast(
75+
str,
76+
viewables.save_viewable_edged_curve3D(
77+
self.edged_curve, filename_without_extension
78+
),
7579
)
7680

7781
def save_light_viewable(self, filename_without_extension: str) -> str:
78-
return viewables.save_light_viewable_edged_curve3D(
79-
self.edged_curve, filename_without_extension
82+
return cast(
83+
str,
84+
viewables.save_light_viewable_edged_curve3D(
85+
self.edged_curve, filename_without_extension
86+
),
8087
)
8188

8289
def inspect(self) -> og_inspector.EdgedCurveInspectionResult:

src/opengeodeweb_back/geode_objects/geode_graph.py

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

45
# Third party imports
56
import opengeode as og
@@ -23,7 +24,7 @@ def geode_object_type(cls) -> GeodeMeshType:
2324
return "Graph"
2425

2526
def native_extension(self) -> str:
26-
return self.graph.native_extension()
27+
return cast(str, self.graph.native_extension())
2728

2829
@classmethod
2930
def is_3D(cls) -> bool:
@@ -50,21 +51,21 @@ def is_loadable(cls, filename: str) -> og.Percentage:
5051

5152
@classmethod
5253
def input_extensions(cls) -> list[str]:
53-
return og.GraphInputFactory.list_creators()
54+
return cast(list[str], og.GraphInputFactory.list_creators())
5455

5556
@classmethod
5657
def output_extensions(cls) -> list[str]:
57-
return og.GraphOutputFactory.list_creators()
58+
return cast(list[str], og.GraphOutputFactory.list_creators())
5859

5960
@classmethod
6061
def object_priority(cls, filename: str) -> int:
61-
return og.graph_object_priority(filename)
62+
return cast(int, og.graph_object_priority(filename))
6263

6364
def is_saveable(self, filename: str) -> bool:
64-
return og.is_graph_saveable(self.graph, filename)
65+
return cast(bool, og.is_graph_saveable(self.graph, filename))
6566

6667
def save(self, filename: str) -> list[str]:
67-
return og.save_graph(self.graph, filename)
68+
return cast(list[str], og.save_graph(self.graph, filename))
6869

6970
def save_viewable(self, filename_without_extension: str) -> str:
7071
return ""

src/opengeodeweb_back/geode_objects/geode_hybrid_solid3d.py

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

45
# Third party imports
56
import opengeode as og
@@ -25,7 +26,7 @@ def geode_object_type(cls) -> GeodeMeshType:
2526
return "HybridSolid3D"
2627

2728
def native_extension(self) -> str:
28-
return self.hybrid_solid.native_extension()
29+
return cast(str, self.hybrid_solid.native_extension())
2930

3031
def builder(self) -> og.HybridSolidBuilder3D:
3132
return og.HybridSolidBuilder3D.create(self.hybrid_solid)
@@ -44,28 +45,34 @@ def is_loadable(cls, filename: str) -> og.Percentage:
4445

4546
@classmethod
4647
def input_extensions(cls) -> list[str]:
47-
return og.HybridSolidInputFactory3D.list_creators()
48+
return cast(list[str], og.HybridSolidInputFactory3D.list_creators())
4849

4950
@classmethod
5051
def output_extensions(cls) -> list[str]:
51-
return og.HybridSolidOutputFactory3D.list_creators()
52+
return cast(list[str], og.HybridSolidOutputFactory3D.list_creators())
5253

5354
@classmethod
5455
def object_priority(cls, filename: str) -> int:
55-
return og.hybrid_solid_object_priority3D(filename)
56+
return cast(int, og.hybrid_solid_object_priority3D(filename))
5657

5758
def is_saveable(self, filename: str) -> bool:
58-
return og.is_hybrid_solid_saveable3D(self.hybrid_solid, filename)
59+
return cast(bool, og.is_hybrid_solid_saveable3D(self.hybrid_solid, filename))
5960

6061
def save(self, filename: str) -> list[str]:
61-
return og.save_hybrid_solid3D(self.hybrid_solid, filename)
62+
return cast(list[str], og.save_hybrid_solid3D(self.hybrid_solid, filename))
6263

6364
def save_viewable(self, filename_without_extension: str) -> str:
64-
return viewables.save_viewable_hybrid_solid3D(
65-
self.hybrid_solid, filename_without_extension
65+
return cast(
66+
str,
67+
viewables.save_viewable_hybrid_solid3D(
68+
self.hybrid_solid, filename_without_extension
69+
),
6670
)
6771

6872
def save_light_viewable(self, filename_without_extension: str) -> str:
69-
return viewables.save_light_viewable_hybrid_solid3D(
70-
self.hybrid_solid, filename_without_extension
73+
return cast(
74+
str,
75+
viewables.save_light_viewable_hybrid_solid3D(
76+
self.hybrid_solid, filename_without_extension
77+
),
7178
)

0 commit comments

Comments
 (0)