fix: make gplugins.tidy3d importable with gdsfactory 9.x - #770
Merged
Conversation
`Waveguide` is a pydantic v1 model whose `cache_path` field was annotated
with `gdsfactory.typings.PathType`. In gdsfactory 9.x that is a PEP 695
type alias (`type PathType = str | pathlib.Path`), which pydantic v1
cannot introspect, so `import gplugins.tidy3d` raised:
RuntimeError: error checking inheritance of PathType (type: TypeAliasType)
Spell the union out in the model. Behaviour is unchanged: str, Path and
None all still validate and coerce as before.
Fixes gdsfactory#769
Co-authored-by: Joaquin Matres <4514346+joamatab@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
jackgdsf
requested review from
ThomasPluck,
joamatab and
nikosavola
as code owners
August 31, 2026 21:16
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes gplugins.tidy3d import failures with gdsfactory 9.x by avoiding the PEP 695 PathType alias in the Pydantic v1 Waveguide model; function annotations elsewhere remain unchanged. File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
pre-commit's lychee hook fails on three links that are reachable in a browser but refuse automated requests: - opg.optica.org (Cloudflare) and 10.1364/* DOIs, which redirect there - www.srim.org, which times out Same class as the hosts already listed in .github/.lychee.toml. Content is unchanged; only the checker config. Co-authored-by: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Co-Authored-By: Claude <noreply@anthropic.com>
joamatab
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #769
Problem
import gplugins.tidy3draises at import time on gdsfactory 9.x:Waveguideis apydantic.v1.BaseModel, and itscache_pathfield was annotated withgdsfactory.typings.PathType, which is now a PEP 695 alias (type PathType = str | pathlib.Path). Pydantic v1 cannot introspectTypeAliasType, so field construction blows up and the whole plugin becomes unimportable.Fix
Spell the union out in the v1 model and drop the now-unused import. The other
PathTypeuses ingplugins/tidy3d/are plain function annotations, which are never introspected, so they are left alone.Verification
With gdsfactory 9.49.0 / gplugins 2.1.4, before the change the import raises; after it:
pre-commit run --files gplugins/tidy3d/modes.pypasses.Summary by Sourcery
Make the Tidy3D plugin importable with gdsfactory 9.x while preserving Waveguide cache path support.
Bug Fixes:
Chores: