{"id":"b0afade11a9d59c2","repo":"pydantic/pydantic","slug":"you-should-use-typing-extensions-typeddict-inste-b0afad","errorCode":null,"errorMessage":"You should use `typing_extensions.TypedDict` instead of `typing.TypedDict` with Python < 3.11. Without it, there is no way to reflect Required/NotRequired keys.","messagePattern":"You should use `typing_extensions\\.TypedDict` instead of `typing\\.TypedDict` with Python < 3\\.11\\. Without it, there is no way to reflect Required/NotRequired keys\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pydantic/v1/annotated_types.py","lineNumber":44,"sourceCode":") -> Type['BaseModel']:\n    \"\"\"\n    Create a `BaseModel` based on the fields of a `TypedDict`.\n    Since `typing.TypedDict` in Python 3.8 does not store runtime information about optional keys,\n    we raise an error if this happens (see https://bugs.python.org/issue38834).\n    \"\"\"\n    field_definitions: Dict[str, Any]\n\n    # Best case scenario: with python 3.9+ or when `TypedDict` is imported from `typing_extensions`\n    if not hasattr(typeddict_cls, '__required_keys__'):\n        raise TypeError(\n            'You should use `typing_extensions.TypedDict` instead of `typing.TypedDict` with Python < 3.9.2. '\n            'Without it, there is no way to differentiate required and optional fields when subclassed.'\n        )\n\n    if is_legacy_typeddict(typeddict_cls) and any(\n        is_typeddict_special(t) for t in typeddict_cls.__annotations__.values()\n    ):\n        raise TypeError(\n            'You should use `typing_extensions.TypedDict` instead of `typing.TypedDict` with Python < 3.11. '\n            'Without it, there is no way to reflect Required/NotRequired keys.'\n        )\n\n    required_keys: FrozenSet[str] = typeddict_cls.__required_keys__  # type: ignore[attr-defined]\n    field_definitions = {\n        field_name: (field_type, Required if field_name in required_keys else None)\n        for field_name, field_type in typeddict_cls.__annotations__.items()\n    }\n\n    return create_model(typeddict_cls.__name__, **kwargs, **field_definitions)\n\n\ndef create_model_from_namedtuple(namedtuple_cls: Type['NamedTuple'], **kwargs: Any) -> Type['BaseModel']:\n    \"\"\"\n    Create a `BaseModel` based on the fields of a named tuple.\n    A named tuple can be created with `typing.NamedTuple` and declared annotations\n    but also with `collections.namedtuple`, in this case we consider all fields","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/pydantic/pydantic/blob/2e5f0e2b4218de31709f1cf9c5bc61ea97a68835/pydantic/v1/annotated_types.py#L26-L62","documentation":"Error \"You should use `typing_extensions.TypedDict` instead of `typing.TypedDict` with Python < 3.11. Without it, there is no way to reflect Required/NotRequired keys.\" thrown in pydantic/pydantic.","triggerScenarios":"Thrown at pydantic/v1/annotated_types.py:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"2e5f0e2b4218de31709f1cf9c5bc61ea97a68835","analyzedAt":"2026-08-04T19:54:21.281Z","schemaVersion":2}