feat: export EffortLevel as a named TypeAlias#939
Open
algojogacor wants to merge 1 commit intoanthropics:mainfrom
Open
feat: export EffortLevel as a named TypeAlias#939algojogacor wants to merge 1 commit intoanthropics:mainfrom
algojogacor wants to merge 1 commit intoanthropics:mainfrom
Conversation
Extract the inline Literal['low', 'medium', 'high', 'xhigh', 'max'] into a named EffortLevel TypeAlias, matching the pattern used by other permission/configuration literals (PermissionMode, SettingSource, etc.). This provides a single source of truth for downstream consumers wrapping the SDK, avoiding drift when the literal values change across versions. Changes: - Added EffortLevel TypeAlias to types.py - Updated ClaudeAgentOptions.effort and ThinkingConfig.effort to use it - Exported from __init__.py and __all__ Fixes anthropics#938
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.
Summary
Fixes #938
Extracts the inline
Literal[low, medium, high, xhigh, max]into a namedEffortLevelTypeAlias, matching the existing pattern used by other literals in the codebase (PermissionMode,SettingSource,SdkBeta,McpServerConnectionStatus, etc.).Why
Single source of truth — downstream SDK wrappers currently must inline the same
Literal[...]type, which drifts when values change (e.g.xhighwas added between 0.1.71 and 0.1.77). With an exported alias, consumers canfrom claude_agent_sdk import EffortLeveland stay in sync automatically.Consistency — the same file already exports several similar small literals as named aliases.
effortwas the only one inlined at use sites.Future-proofing — when the literal values expand again, only the alias definition needs updating.
Changes
src/claude_agent_sdk/types.py:TypeAliasto typing importsEffortLevel: TypeAlias = Literal[low, medium, high, xhigh, max]ClaudeAgentOptions.effort(line 99) to useEffortLevelThinkingConfig.effort(line 1867) to useEffortLevelsrc/claude_agent_sdk/__init__.py:EffortLevelto imports and__all__Testing
ruff checkpasses with no errorsLiteral[...]at runtime)