Skip to content

Conversation

mikaeloduh
Copy link

@mikaeloduh mikaeloduh commented Jul 7, 2025

This PR addresses an import issue with typing_extensions in the SDK.

Problem:

  • The current code unconditionally imports typing_extensions.NotRequired
  • However, in pyproject.toml, typing_extensions is only installed for Python < 3.11
  • On Python 3.11+, typing.NotRequired exists, but the package may not be installed
  • This causes ModuleNotFoundError on a clean install with Python 3.11+

Solution:

  • Use version-conditional imports to fallback to typing on Python 3.11+
  • Ensures compatibility without forcing unnecessary dependencies

The SDK unconditionally imported `typing_extensions.NotRequired`, but `typing_extensions` is declared as a dependency only for Python < 3.11 in pyproject.toml. On Python 3.11+ this led to a ModuleNotFoundError on a clean install.

This commit replaces the unconditional import with a version-guarded
Copy link
Collaborator

@dicksontsai dicksontsai left a comment

Choose a reason for hiding this comment

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

This PR isn't strictly necessary because anyio will pull in typing_extensions, but it's fine to merge after addressing imports.

@@ -1,5 +1,8 @@
"""Tests for Claude SDK type definitions."""

import sys
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to import sys and pytest

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