Skip to content

fix: Never import from typing_extensions at runtime #2391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarcoGorelli
Copy link
Member

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

@dangotbanned
Copy link
Member

dangotbanned commented Apr 16, 2025

@MarcoGorelli could we slow down a bit on this one?

My read on this, was that the import wasn't the issue?

pyinstaller/pyinstaller-hooks-contrib#902 (comment)

Sure, thanks - would it help if we just removed the runtime import from Narwhals anyway?

Sure, if you don't need it. (But dynamic import with find_spec is not really the problematic part - it is the metadata query. Because while our analysis will miss the reference to typing_extensions made via find_spec, there are plenty of direct import typing_extensions later on, which allow us to pick up the module - mostly because we do not handle TYPE_CHECKING as no-op codepath...).

You could also catch the importlib.metadata.PackageNotFoundError when calling importlib.metadata.version(_TYPING_EXTENSIONS) in narwhals-dev/narwhals@7059f5b/narwhals/_translate.py#L20 (blame).

I just wanna be sure I understand the issue fully first

Edit

I replied in (pyinstaller/pyinstaller-hooks-contrib#902 (comment))

@dangotbanned
Copy link
Member

dangotbanned commented Apr 16, 2025

@MarcoGorelli okay it seems we're all good! πŸŽ‰

pyinstaller/pyinstaller-hooks-contrib#902 (comment)

As far as I'm concerned, there's no need to change anything on your side.

I followed up and checked, the fix they've added is pretty standard and they've used it in lots of popular packages

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.

2 participants