Skip to content

Commit c760141

Browse files
conradleeclaude
andcommitted
Remove additional dead code: single-member union collapse path
After removing simplify_nullable_unions, the code path that handled unions collapsing to a single member (line 147-149) became unreachable. This path was only hit when simplify_nullable_unions converted: anyOf: [{type: 'string'}, {type: 'null'}] → {type: 'string', nullable: true} Without that feature, multi-member unions can't collapse to 1 member naturally. Removed 4 more lines of unreachable code. This should restore 100% coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9254fd5 commit c760141

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

pydantic_ai_slim/pydantic_ai/_json_schema.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ def _handle_union(self, schema: JsonSchema, union_kind: Literal['anyOf', 'oneOf'
144144

145145
handled = [self._handle(member) for member in members]
146146

147-
if len(handled) == 1:
148-
# In this case, no need to retain the union
149-
return handled[0] | schema
150-
151147
# If we have keys besides the union kind (such as title or discriminator), keep them without modifications
152148
schema = schema.copy()
153149
schema[union_kind] = handled

0 commit comments

Comments
 (0)