Skip to content

Commit 9105449

Browse files
fix: cleanup unsupported module (#1690)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent f746d51 commit 9105449

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

doc/changelog.d/1690.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cleanup unsupported module

src/ansys/geometry/core/modeler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
from ansys.geometry.core.logger import LOG
4141
from ansys.geometry.core.misc.checks import check_type, min_backend_version
4242
from ansys.geometry.core.misc.options import ImportOptions
43-
from ansys.geometry.core.misc.unsupported import UnsupportedCommands
4443
from ansys.geometry.core.tools.measurement_tools import MeasurementTools
4544
from ansys.geometry.core.tools.prepare_tools import PrepareTools
4645
from ansys.geometry.core.tools.repair_tools import RepairTools
46+
from ansys.geometry.core.tools.unsupported import UnsupportedCommands
4747
from ansys.geometry.core.typing import Real
4848

4949
if TYPE_CHECKING: # pragma: no cover
@@ -120,6 +120,9 @@ def __init__(
120120
backend_type=backend_type,
121121
)
122122

123+
# Maintaining references to all designs within the modeler workspace
124+
self._designs: dict[str, "Design"] = {}
125+
123126
# Initialize the RepairTools - Not available on Linux
124127
# TODO: delete "if" when Linux service is able to use repair tools
125128
# https://github.com/ansys/pyansys-geometry/issues/1319
@@ -135,9 +138,6 @@ def __init__(
135138
self._geometry_commands = GeometryCommands(self._grpc_client)
136139
self._unsupported = UnsupportedCommands(self._grpc_client, self)
137140

138-
# Maintaining references to all designs within the modeler workspace
139-
self._designs: dict[str, "Design"] = {}
140-
141141
# Check if the backend allows for multiple designs and throw warning if needed
142142
if not self.client.multiple_designs_allowed:
143143
LOG.warning(

src/ansys/geometry/core/tools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
)
3131
from ansys.geometry.core.tools.repair_tool_message import RepairToolMessage
3232
from ansys.geometry.core.tools.repair_tools import RepairTools
33+
from ansys.geometry.core.tools.unsupported import PersistentIdType, UnsupportedCommands

src/ansys/geometry/core/misc/unsupported.py renamed to src/ansys/geometry/core/tools/unsupported.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from ansys.api.geometry.v0.unsupported_pb2_grpc import UnsupportedStub
3030
from ansys.geometry.core.connection import GrpcClient
3131
from ansys.geometry.core.errors import protect_grpc
32-
from ansys.geometry.core.misc import auxiliary
32+
from ansys.geometry.core.misc.auxiliary import get_all_bodies_from_design
3333
from ansys.geometry.core.misc.checks import (
3434
min_backend_version,
3535
)
@@ -38,6 +38,7 @@
3838
from ansys.geometry.core.designer.body import Body
3939
from ansys.geometry.core.designer.edge import Edge
4040
from ansys.geometry.core.designer.face import Face
41+
from ansys.geometry.core.modeler import Modeler
4142

4243

4344
@unique
@@ -58,17 +59,17 @@ class UnsupportedCommands:
5859
"""
5960

6061
@protect_grpc
61-
def __init__(self, grpc_client: GrpcClient, modeler):
62+
def __init__(self, grpc_client: GrpcClient, modeler: "Modeler"):
6263
"""Initialize an instance of the ``UnsupportedCommands`` class."""
6364
self._grpc_client = grpc_client
6465
self._unsupported_stub = UnsupportedStub(self._grpc_client.channel)
6566
self.__id_map = {}
6667
self.__modeler = modeler
67-
self.__current_design = None
68+
self.__current_design = modeler.get_active_design()
6869

6970
@protect_grpc
7071
@min_backend_version(25, 2, 0)
71-
def __fill_imported_id_map(self, id_type: "PersistentIdType") -> None:
72+
def __fill_imported_id_map(self, id_type: PersistentIdType) -> None:
7273
"""Populate the persistent id map for caching.
7374
7475
Parameters
@@ -96,7 +97,7 @@ def __clear_cache(self) -> None:
9697

9798
@protect_grpc
9899
@min_backend_version(25, 2, 0)
99-
def __is_occurrence(self, master: "EntityIdentifier", occ: "str") -> bool:
100+
def __is_occurrence(self, master: EntityIdentifier, occ: str) -> bool:
100101
"""Determine if the master is the master of the occurrence.
101102
102103
Parameters
@@ -118,7 +119,7 @@ def __is_occurrence(self, master: "EntityIdentifier", occ: "str") -> bool:
118119
@protect_grpc
119120
@min_backend_version(25, 2, 0)
120121
def __get_moniker_from_import_id(
121-
self, id_type: "PersistentIdType", import_id: "str"
122+
self, id_type: PersistentIdType, import_id: str
122123
) -> "EntityIdentifier | None":
123124
"""Look up the moniker from the id map.
124125
@@ -148,7 +149,7 @@ def __get_moniker_from_import_id(
148149

149150
@protect_grpc
150151
@min_backend_version(25, 2, 0)
151-
def set_export_id(self, moniker: "str", id_type: "PersistentIdType", value: "str") -> None:
152+
def set_export_id(self, moniker: str, id_type: PersistentIdType, value: str) -> None:
152153
"""Set the persistent id for the moniker.
153154
154155
Parameters
@@ -175,7 +176,7 @@ def set_export_id(self, moniker: "str", id_type: "PersistentIdType", value: "str
175176
@protect_grpc
176177
@min_backend_version(25, 2, 0)
177178
def get_body_occurrences_from_import_id(
178-
self, import_id: "str", id_type: "PersistentIdType"
179+
self, import_id: str, id_type: PersistentIdType
179180
) -> list["Body"]:
180181
"""Get all body occurrences whose master has the given import id.
181182
@@ -194,19 +195,19 @@ def get_body_occurrences_from_import_id(
194195
moniker = self.__get_moniker_from_import_id(id_type, import_id)
195196

196197
if moniker is None:
197-
return list()
198+
return []
198199

199200
design = self.__modeler.get_active_design()
200201
return [
201202
body
202-
for body in auxiliary.get_all_bodies_from_design(design)
203+
for body in get_all_bodies_from_design(design)
203204
if self.__is_occurrence(moniker, body.id)
204205
]
205206

206207
@protect_grpc
207208
@min_backend_version(25, 2, 0)
208209
def get_face_occurrences_from_import_id(
209-
self, import_id: "str", id_type: "PersistentIdType"
210+
self, import_id: str, id_type: PersistentIdType
210211
) -> list["Face"]:
211212
"""Get all face occurrences whose master has the given import id.
212213
@@ -225,20 +226,20 @@ def get_face_occurrences_from_import_id(
225226
moniker = self.__get_moniker_from_import_id(id_type, import_id)
226227

227228
if moniker is None:
228-
return list()
229+
return []
229230

230231
design = self.__modeler.get_active_design()
231232
return [
232233
face
233-
for body in auxiliary.get_all_bodies_from_design(design)
234+
for body in get_all_bodies_from_design(design)
234235
for face in body.faces
235236
if self.__is_occurrence(moniker, face.id)
236237
]
237238

238239
@protect_grpc
239240
@min_backend_version(25, 2, 0)
240241
def get_edge_occurrences_from_import_id(
241-
self, import_id: "str", id_type: "PersistentIdType"
242+
self, import_id: str, id_type: PersistentIdType
242243
) -> list["Edge"]:
243244
"""Get all edge occurrences whose master has the given import id.
244245
@@ -257,12 +258,12 @@ def get_edge_occurrences_from_import_id(
257258
moniker = self.__get_moniker_from_import_id(id_type, import_id)
258259

259260
if moniker is None:
260-
return list()
261+
return []
261262

262263
design = self.__modeler.get_active_design()
263264
return [
264265
edge
265-
for body in auxiliary.get_all_bodies_from_design(design)
266+
for body in get_all_bodies_from_design(design)
266267
for edge in body.edges
267268
if self.__is_occurrence(moniker, edge.id)
268269
]

tests/integration/test_design_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
from ansys.geometry.core.designer.design import DesignFileFormat
3434
from ansys.geometry.core.math import Plane, Point2D, Point3D, UnitVector3D, Vector3D
3535
from ansys.geometry.core.misc import UNITS
36-
from ansys.geometry.core.misc.unsupported import PersistentIdType
3736
from ansys.geometry.core.sketch import Sketch
37+
from ansys.geometry.core.tools.unsupported import PersistentIdType
3838

3939
from .conftest import FILES_DIR, IMPORT_FILES_DIR, skip_if_linux
4040

0 commit comments

Comments
 (0)