fix: support bare dict as predict output type#2824
Merged
michaeldwan merged 2 commits intomainfrom Mar 9, 2026
Merged
Conversation
FieldType.from_type did not handle dict-origin types, causing 'unsupported Cog type Dict' during schema validation. Add a branch to map dict/Dict[K,V] to PrimitiveType.ANY (opaque JSON object), matching the static Go schema generator. Also add integration tests for type coverage gaps: dict output, bool input/output, ConcatenateIterator[str], Iterator[str], list[str] output, and list[int] input/output.
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
ValueError: unsupported Cog type Dictwhen using baredictas a predict return typeBug fix
FieldType.from_typeinpython/cog/_adt.pydid not handle dict-origin types. When a predictor declared-> dict, the legacy Python schema generator converted it toDict[str, Any], which fell through to the catch-all branch and raisedValueError: unsupported Cog type Dict. The static Go schema generator already handled this correctly viaSchemaAnyType().The fix adds a branch for dict-origin types, mapping them to
PrimitiveType.ANY(opaque JSON object{"type": "object"}), consistent with the Go path.New integration tests
dict_output-> dictoutput (the fix)bool_input_outputboolas direct input + outputconcatenate_iterator_outputConcatenateIterator[str]outputiterator_string_outputIterator[str]outputlist_string_outputlist[str]outputlist_int_input_outputlist[int]input + output