33from __future__ import annotations
44
55from abc import ABC
6- from typing import Any , Callable , Literal , Optional , Union
6+ from typing import TYPE_CHECKING , Any , Callable , Literal , Optional , Union
77
88import numpy as np
99import pydantic .v1 as pydantic
2121
2222from . import base
2323
24+ if TYPE_CHECKING :
25+ from trimesh import Trimesh
26+
2427AREA_SIZE_THRESHOLD = 1e-36
2528
2629
@@ -44,7 +47,7 @@ class TriangleMesh(base.Geometry, ABC):
4447
4548 @pydantic .root_validator (pre = True )
4649 @verify_packages_import (["trimesh" ])
47- def _validate_trimesh_library (cls , values ) :
50+ def _validate_trimesh_library (cls , values : dict [ str , Any ]) -> dict [ str , Any ] :
4851 """Check if the trimesh package is imported as a validator."""
4952 return values
5053
@@ -303,7 +306,7 @@ def from_vertices_faces(cls, vertices: np.ndarray, faces: np.ndarray) -> Triangl
303306 @verify_packages_import (["trimesh" ])
304307 def _triangles_to_trimesh (
305308 cls , triangles : np .ndarray
306- ): # -> TrimeshType: We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
309+ ) -> Trimesh : # -> We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
307310 """Convert an (N, 3, 3) numpy array of triangles to a ``trimesh.Trimesh``."""
308311 import trimesh
309312
@@ -492,7 +495,7 @@ def from_height_function(
492495 @verify_packages_import (["trimesh" ])
493496 def trimesh (
494497 self ,
495- ): # -> TrimeshType: We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
498+ ) -> Trimesh : # -> We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
496499 """A ``trimesh.Trimesh`` object representing the custom surface mesh geometry."""
497500 return self ._triangles_to_trimesh (self .triangles )
498501
0 commit comments