{"id":"989c113154e1a625","repo":"pydantic/pydantic","slug":"invalid-annotated-type-989c11","errorCode":"invalid-annotated-type","errorMessage":"'{annotation}' cannot annotate '{annotated_type}'.","messagePattern":"'(.+?)' cannot annotate '(.+?)'\\.","errorType":"exception","errorClass":"PydanticUserError","httpStatus":null,"severity":"error","filePath":"pydantic/types.py","lineNumber":2234,"sourceCode":"                kibit, mibit, gibit, tibit, pibit, eibit (bit units).\n\n        Returns:\n            The byte size in the new unit.\n        \"\"\"\n        try:\n            unit_div = self.byte_sizes[unit.lower()]\n        except KeyError:\n            raise PydanticCustomError('byte_size_unit', 'Could not interpret byte unit: {unit}', {'unit': unit})\n\n        return self / unit_div\n\n\n# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DATE TYPES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n\ndef _check_annotated_type(annotated_type: str, expected_type: str, annotation: str) -> None:\n    if annotated_type != expected_type:\n        raise PydanticUserError(f\"'{annotation}' cannot annotate '{annotated_type}'.\", code='invalid-annotated-type')\n\n\nif TYPE_CHECKING:\n    PastDate = Annotated[date, ...]\n    FutureDate = Annotated[date, ...]\nelse:\n\n    class PastDate:\n        \"\"\"A date in the past.\"\"\"\n\n        @classmethod\n        def __get_pydantic_core_schema__(\n            cls, source: type[Any], handler: GetCoreSchemaHandler\n        ) -> core_schema.CoreSchema:\n            if cls is source:\n                # used directly as a type\n                return core_schema.date_schema(now_op='past')\n            else:","sourceCodeStart":2216,"sourceCodeEnd":2252,"githubUrl":"https://github.com/pydantic/pydantic/blob/2e5f0e2b4218de31709f1cf9c5bc61ea97a68835/pydantic/types.py#L2216-L2252","documentation":"Error \"'{annotation}' cannot annotate '{annotated_type}'.\" thrown in pydantic/pydantic.","triggerScenarios":"Thrown at pydantic/types.py:2234 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}