Strengthen tidy3d-extras packaging test #2884
Open
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.
Some minor improvements to packaging:
disable_local_subpixel
should restore the config even if the function it wraps errorsGreptile Overview
Updated On: 2025-10-10 17:41:16 UTC
Greptile Summary
This PR strengthens the packaging system for the optional
tidy3d-extras
dependency by improving error handling and module detection logic. The changes refactor thesupports_local_subpixel
decorator intidy3d/packaging.py
to usefind_spec()
for more robust module existence checking before attempting imports, providing clearer error differentiation between "module not found" vs "module failed to initialize". Thedisable_local_subpixel
decorator is also enhanced with proper try/finally blocks to ensure configuration state is always restored even when exceptions occur.Additionally, a new test function
test_tidy3d_extras()
is added totests/test_components/test_packaging.py
that validates the packaging behavior for both scenarios when tidy3d-extras is available and when it's not. This test ensures that the@supports_local_subpixel
decorator correctly detects the module, loads features, and sets appropriate flags. The changes improve the reliability of Tidy3D's optional dependency handling, which is critical for a library that extends core functionality through optional packages.Important Files Changed
Changed Files
Confidence score: 4/5
supports_local_subpixel
decorator logic intidy3d/packaging.py
Sequence Diagram