Skip to content

Commit cf851ae

Browse files
stainless-app[bot]stainless-bot
authored andcommittedFeb 6, 2025·
fix(internal): add back custom header naming support (#861)
1 parent 0cdb81d commit cf851ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/anthropic/_models.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,16 @@ def construct_type(*, value: object, type_: object) -> object:
442442
443443
If the given value does not match the expected type then it is returned as-is.
444444
"""
445+
446+
# store a reference to the original type we were given before we extract any inner
447+
# types so that we can properly resolve forward references in `TypeAliasType` annotations
448+
original_type = None
449+
445450
# we allow `object` as the input type because otherwise, passing things like
446451
# `Literal['value']` will be reported as a type error by type checkers
447452
type_ = cast("type[object]", type_)
448453
if is_type_alias_type(type_):
454+
original_type = type_ # type: ignore[unreachable]
449455
type_ = type_.__value__ # type: ignore[unreachable]
450456

451457
# unwrap `Annotated[T, ...]` -> `T`
@@ -462,7 +468,7 @@ def construct_type(*, value: object, type_: object) -> object:
462468

463469
if is_union(origin):
464470
try:
465-
return validate_type(type_=cast("type[object]", type_), value=value)
471+
return validate_type(type_=cast("type[object]", original_type or type_), value=value)
466472
except Exception:
467473
pass
468474

0 commit comments

Comments
 (0)
Please sign in to comment.