-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Initial Checks
- I confirm that I'm using Pydantic V2
Description
When validating a list of unhashable items as a set using a TypeAdapter
, pydantic raises a TypeError
as opposed to a ValidationError
.
Example Code
from pydantic import TypeAdapter
TypeAdapter(set).validate_python([{"a":"b"}])
# E TypeError: unhashable type: 'dict'
Probably related to #8016 but I think this is more clearly a bug, since
from pydantic import TypeAdapter
TypeAdapter(set).validate_python({"a":"b"})
# E pydantic_core._pydantic_core.ValidationError: 1 validation error for set[any]
# E Input should be a valid set [type=set_type, input_value={'a': 'b'}, input_type=dict]
# E For further information visit https://errors.pydantic.dev/2.10/v/set_type
Works as expected.
Python, Pydantic & OS Version
pydantic version: 2.10.1
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /workspaces/pydantic-ai/.venv/lib/python3.11/site-packages/pydantic
python version: 3.11.4 (main, Jun 7 2023, 18:32:58) [GCC 10.2.1 20210110]
platform: Linux-6.8.0-1020-gcp-x86_64-with-glibc2.31
related packages: typing_extensions-4.12.2 mypy-1.13.0 pyright-1.1.389 fastapi-0.115.5
commit: unknown