diff --git a/src/claude_code_sdk/types.py b/src/claude_code_sdk/types.py index bd3c726..8cb662a 100644 --- a/src/claude_code_sdk/types.py +++ b/src/claude_code_sdk/types.py @@ -1,10 +1,14 @@ """Type definitions for Claude SDK.""" +import sys from dataclasses import dataclass, field from pathlib import Path from typing import Any, Literal, TypedDict -from typing_extensions import NotRequired # For Python < 3.11 compatibility +if sys.version_info >= (3, 11): + from typing import NotRequired +else: + from typing_extensions import NotRequired # Permission modes PermissionMode = Literal["default", "acceptEdits", "bypassPermissions"] diff --git a/tests/test_types.py b/tests/test_types.py index 6046292..5d53375 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,5 +1,8 @@ """Tests for Claude SDK type definitions.""" +import sys +import importlib +import pytest from claude_code_sdk import ( AssistantMessage, ClaudeCodeOptions, @@ -56,6 +59,14 @@ def test_result_message(self): assert msg.total_cost_usd == 0.01 assert msg.session_id == "session-123" + def test_import_types_module(self): + """ + Smoke test to ensure claude_code_sdk.types imports without errors + and defines NotRequired. + """ + module = importlib.reload(importlib.import_module("claude_code_sdk.types")) + assert hasattr(module, "NotRequired"), "claude_code_sdk.types should define NotRequired" + class TestOptions: """Test Options configuration."""