feat(tidy3d): FXC-3958-mypy-implement-type-defs-in-config-material-li… #2957
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…brary-and-geometry
follow up of #2921
Here, all functions of the packages
tidy3d/config,tidy3d/material_libraryandtidy3d/components/geometrywere extended with typedefs for mypy.Greptile Overview
Updated On: 2025-11-04 11:34:44 UTC
Greptile Summary
This PR adds comprehensive type annotations to three packages (
tidy3d/config,tidy3d/material_library, andtidy3d/components/geometry) as a follow-up to PR #2921. The changes enable mypy type checking by adding these packages to the mypy configuration inpyproject.toml.Key changes:
LogLevel,NDArray,Cell,Trimesh, etc.) and usedTYPE_CHECKINGguards for forward referencestyping.Selffor methods returning the same typeNDArray[float]andUniontypesIssues found:
tidy3d/components/geometry/base.py, the__or__method returnsGeometryGroupbut is annotated as returningClipOperationConfidence Score: 4/5
__or__method that needs to be corrected. The change is otherwise straightforward and low-risk, consisting primarily of adding type hints without changing logic.__or__methodImportant Files Changed
File Analysis
__or__method (returns GeometryGroup but annotated as ClipOperation)Sequence Diagram
sequenceDiagram participant Dev as Developer participant MyPy as MyPy Type Checker participant Config as tidy3d/config participant MatLib as tidy3d/material_library participant Geom as tidy3d/components/geometry Dev->>MyPy: Run mypy type checking MyPy->>Config: Check type annotations Config-->>MyPy: ✓ All types valid MyPy->>MatLib: Check type annotations MatLib-->>MyPy: ✓ All types valid MyPy->>Geom: Check type annotations Geom-->>MyPy: ⚠️ __or__ return type mismatch MyPy->>Dev: Report type errors