chore: improve error message for tidy3d-extras#2879
Merged
Conversation
Contributor
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changesNo lines with coverage information in this diff. |
ade9dc0 to
4fadd5f
Compare
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.
Greptile Overview
Updated On: 2025-10-08 19:17:32 UTC
Summary
This PR improves the error message displayed when the 'tidy3d-extras' package fails to initialize, typically due to authentication issues with an invalid API key. The change is focused on enhancing user experience by providing clear, actionable guidance.The modification occurs in the
packaging.pyfile within thesupports_local_subpixeldecorator context. When the extras package cannot be properly initialized, users previously received a generic error message indicating an API key issue but no clear resolution path. The enhanced error message now explicitly tells users they can suppress the error by settingconfig.use_local_subpixel=False, which allows them to continue using the main tidy3d functionality without the extras features.This change fits naturally into the existing error handling infrastructure and maintains the same control flow - it simply extends the existing
Tidy3dImportErrorwith more helpful guidance. The improvement addresses a common user pain point where authentication failures would block usage even when the extras functionality wasn't strictly needed.Important Files Changed
Changed Files
Confidence score: 5/5
Sequence Diagram
sequenceDiagram participant User participant Function as "Decorated Function" participant Config as "config.use_local_subpixel" participant TidyExtras as "tidy3d_extras module" participant Logger as "log.warning" User->>Function: "Call function with @supports_local_subpixel decorator" Function->>Config: "Check config.use_local_subpixel value" alt config.use_local_subpixel is False Function->>TidyExtras: "Set use_local_subpixel = False, mod = None" Function->>User: "Execute original function" else config.use_local_subpixel is not False alt tidy3d_extras["mod"] is None Function->>TidyExtras: "Try to import tidy3d_extras" alt ImportError occurs TidyExtras->>Function: "ImportError exception" Function->>TidyExtras: "Set mod = None, use_local_subpixel = False" alt config.use_local_subpixel is True Function->>User: "Raise Tidy3dImportError with improved message" else Function->>User: "Continue execution" end else Import successful TidyExtras->>Function: "Return tidy3d_extras_mod" Function->>TidyExtras: "Check version" alt version is None Function->>TidyExtras: "Set mod = None, use_local_subpixel = False" Function->>User: "Raise Tidy3dImportError about API key" else version exists alt version != __version__ Function->>Logger: "Log warning about version mismatch" end Function->>TidyExtras: "Check features" TidyExtras->>Function: "Return features list" Function->>TidyExtras: "Set mod and use_local_subpixel based on features" end end end Function->>User: "Execute original function" end