{"id":"16ef1f82121c87e1","repo":"pydantic/pydantic","slug":"type-adapter-config-unused","errorCode":"type-adapter-config-unused","errorMessage":"Cannot use `config` when the type is a BaseModel, dataclass or TypedDict. These types can have their own config and setting the config via the `config` parameter to TypeAdapter will not override it, thus the `config` you passed to TypeAdapter becomes meaningless, which is probably not what you want.","messagePattern":"Cannot use `config` when the type is a BaseModel, dataclass or TypedDict\\. These types can have their own config and setting the config via the `config` parameter to TypeAdapter will not override it, thus the `config` you passed to TypeAdapter becomes meaningless, which is probably not what you want\\.","errorType":"exception","errorClass":"PydanticUserError","httpStatus":null,"severity":"error","filePath":"pydantic/type_adapter.py","lineNumber":203,"sourceCode":"    def __init__(\n        self,\n        type: Any,\n        *,\n        config: ConfigDict | None = ...,\n        _parent_depth: int = ...,\n        module: str | None = ...,\n    ) -> None: ...\n\n    def __init__(\n        self,\n        type: Any,\n        *,\n        config: ConfigDict | None = None,\n        _parent_depth: int = 2,\n        module: str | None = None,\n    ) -> None:\n        if _type_has_config(type) and config is not None:\n            raise PydanticUserError(\n                'Cannot use `config` when the type is a BaseModel, dataclass or TypedDict.'\n                ' These types can have their own config and setting the config via the `config`'\n                ' parameter to TypeAdapter will not override it, thus the `config` you passed to'\n                ' TypeAdapter becomes meaningless, which is probably not what you want.',\n                code='type-adapter-config-unused',\n            )\n\n        self._type = type\n        self._config = config\n        self._parent_depth = _parent_depth\n        self.pydantic_complete = False\n\n        parent_frame = self._fetch_parent_frame()\n        if isinstance(type, types.FunctionType):\n            # Special case functions, which are *not* pushed to the `NsResolver` stack and without this special case\n            # would only have access to the parent namespace where the `TypeAdapter` was instantiated (if the function is defined\n            # in another module, we need to look at that module's globals).\n            if parent_frame is not None:","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/pydantic/pydantic/blob/2e5f0e2b4218de31709f1cf9c5bc61ea97a68835/pydantic/type_adapter.py#L185-L221","documentation":"TypeAdapter accepts a config parameter, but only for types that don't carry their own config. _type_has_config returns True for BaseModel, pydantic dataclass, and TypedDict subclasses, which define config internally. Passing config for such a type would be silently ignored, so pydantic raises PydanticUserError code 'type-adapter-config-unused' instead.","triggerScenarios":"TypeAdapter(MyModel, config=ConfigDict(strict=True)) where MyModel subclasses BaseModel; TypeAdapter over a dataclass or TypedDict with a config kwarg.","commonSituations":"Trying to override a model's strict/coerce behavior at the adapter level; wrapping an existing model with extra validation config.","solutions":["Set the config on the model itself: class MyModel(BaseModel): model_config = ConfigDict(strict=True).","For plain/non-config types (e.g. int, list[str], a non-pydantic dataclass), the config parameter is valid.","If you need different config without editing the model, create a subclass with the desired model_config and adapt that."],"exampleFix":"# before\nTypeAdapter(MyModel, config=ConfigDict(strict=True))\n# after\nclass StrictModel(MyModel):\n    model_config = ConfigDict(strict=True)\nTypeAdapter(StrictModel)","handlingStrategy":"validation","validationCode":"from pydantic._internal import _model_construction\nfrom pydantic import BaseModel, TypeAdapter\n\ndef adapter_for(tp, config=None):\n    from pydantic.type_adapter import _type_has_config\n    if config is not None and _type_has_config(tp):\n        raise ValueError(f'{tp!r} carries its own config; set model_config on the type instead')\n    return TypeAdapter(tp, config=config)","typeGuard":"from pydantic.type_adapter import _type_has_config\ndef type_accepts_adapter_config(tp) -> bool:\n    return not _type_has_config(tp)","tryCatchPattern":null,"preventionTips":["Set config on the model/dataclass/TypedDict itself, not on the TypeAdapter wrapping it.","Only pass config to TypeAdapter for plain/non-config types.","Create a subclass with the desired model_config if you need a different config without editing the original."],"tags":["type-adapter","config","basemodel","dataclass","typeddict"],"analyzedSha":"2e5f0e2b4218de31709f1cf9c5bc61ea97a68835","analyzedAt":"2026-08-04T19:54:21.281Z","schemaVersion":2}