Skip to content

Commit 9ad91f1

Browse files
marcorudolphflexyaugenst-flex
authored andcommitted
feat(tidy3d): FXC-3958-mypy-implement-type-defs-in-config-material-library-and-geometry
1 parent 88a8d75 commit 9ad91f1

File tree

12 files changed

+248
-195
lines changed

12 files changed

+248
-195
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ python_files = "*.py"
319319
python_version = "3.10"
320320
files = [
321321
"tidy3d/web",
322+
"tidy3d/config",
323+
"tidy3d/material_library",
324+
"tidy3d/components/geometry"
322325
]
323326
ignore_missing_imports = true
324327
follow_imports = "skip"

tidy3d/components/geometry/base.py

Lines changed: 77 additions & 69 deletions
Large diffs are not rendered by default.

tidy3d/components/geometry/mesh.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from abc import ABC
6-
from typing import Any, Callable, Literal, Optional, Union
6+
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union
77

88
import numpy as np
99
import pydantic.v1 as pydantic
@@ -21,6 +21,9 @@
2121

2222
from . import base
2323

24+
if TYPE_CHECKING:
25+
from trimesh import Trimesh
26+
2427
AREA_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

Comments
 (0)