Skip to content

Conversation

@weiliangjin2021
Copy link
Collaborator

@weiliangjin2021 weiliangjin2021 commented Nov 14, 2025

Greptile Overview

Greptile Summary

This PR improves error messaging in the tidy3d_extras import checking function by:

  • Escaping square brackets in shell command examples (pip install tidy3d\[extras]) to prevent them from being interpreted as glob patterns in some shells
  • Adding a check for __version__ attribute existence before attempting to access it, providing a clearer error message when the package didn't initialize properly

Issue Found:

  • Missing space after period in error message on line 215

Confidence Score: 4/5

  • This PR is safe to merge with one minor formatting fix needed
  • The changes are straightforward improvements to error messages. The escaped square brackets fix a real issue where shells could interpret the brackets as globs. The added __version__ check provides better error handling. One syntax issue (missing space) needs correction before merging.
  • tidy3d/packaging.py needs a minor spacing fix on line 215

Important Files Changed

File Analysis

Filename Score Overview
tidy3d/packaging.py 4/5 Escapes square brackets in error messages and adds __version__ check; missing space after period on line 215

Sequence Diagram

sequenceDiagram
    participant User
    participant Function as _check_tidy3d_extras_available()
    participant ImportSystem as Import System
    participant Module as tidy3d_extras module

    User->>Function: Call function requiring tidy3d_extras
    Function->>Function: Check if already loaded (tidy3d_extras["mod"])
    alt Already loaded
        Function-->>User: Return (skip checks)
    end
    
    Function->>ImportSystem: find_spec("tidy3d_extras")
    alt Module not found
        ImportSystem-->>Function: None
        Function->>User: Raise error with escaped brackets
    end
    
    Function->>Module: import tidy3d_extras
    alt Import fails
        Module-->>Function: ImportError
        Function->>User: Raise Tidy3dImportError
    end
    
    Function->>Module: Check hasattr(__version__)
    alt __version__ missing (NEW CHECK)
        Module-->>Function: False
        Function->>User: Raise error with install instructions
    end
    
    Function->>Module: Get __version__
    alt version is None
        Module-->>Function: None
        Function->>User: Raise error (invalid API key)
    end
    
    alt version mismatch
        Function->>User: Raise error with version info
    end
    
    Function->>Function: Store module reference
    Function-->>User: Success
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/packaging.py (0.0%): Missing lines 213-214

Summary

  • Total: 2 lines
  • Missing: 2 lines
  • Coverage: 0%

tidy3d/packaging.py

Lines 209-218

  209         raise Tidy3dImportError(
  210             "The package 'tidy3d-extras' did not initialize correctly."
  211         ) from exc
  212 
! 213     if not hasattr(tidy3d_extras_mod, "__version__"):
! 214         raise Tidy3dImportError(
  215             "The package 'tidy3d-extras' did not initialize correctly. "
  216             "Please install the 'tidy3d-extras' package using, for "
  217             r"example, 'pip install tidy3d\[extras]'."
  218         )

@weiliangjin2021 weiliangjin2021 force-pushed the weiliang/FXC-2556-packaging branch from 4efa669 to c37d0e8 Compare November 14, 2025 17:52
@daquinteroflex daquinteroflex force-pushed the weiliang/FXC-2556-packaging branch from c37d0e8 to f2a5c4d Compare November 17, 2025 10:18
@daquinteroflex daquinteroflex added this pull request to the merge queue Nov 17, 2025
Merged via the queue into develop with commit f84536b Nov 17, 2025
48 checks passed
@daquinteroflex daquinteroflex deleted the weiliang/FXC-2556-packaging branch November 17, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants