{"record":{"id":"384f2c4f7b71ecf0","repo":"pola-rs/polars","slug":"expected-type-int-str-got-qualified-type-nam","errorCode":null,"errorMessage":"expected type 'int | str', got {qualified_type_name(item)!r} ({item!r})","messagePattern":"expected type 'int \\| str', got (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/datatype_expr/struct.py","lineNumber":24,"sourceCode":"\nclass DataTypeExprStructNameSpace:\n    \"\"\"Namespace for struct datatype expressions.\"\"\"\n\n    _accessor = \"struct\"\n\n    def __init__(self, expr: pl.DataTypeExpr) -> None:\n        self._pydatatype_expr = expr._pydatatype_expr\n\n    def __getitem__(self, item: str | int) -> pl.DataTypeExpr:\n        if isinstance(item, str):\n            return self.field_dtype(item)\n        elif isinstance(item, int):\n            return pl.DataTypeExpr._from_pydatatype_expr(\n                self._pydatatype_expr.struct_field_dtype_by_index(item)\n            )\n        else:\n            msg = f\"expected type 'int | str', got {qualified_type_name(item)!r} ({item!r})\"\n            raise TypeError(msg)\n\n    def field_dtype(self, field_name: str) -> pl.DataTypeExpr:\n        \"\"\"\n\n        Get the DataType of field with a specific field name.\n\n        Notes\n        -----\n        The `struct` namespace has implemented `__getitem__` so you can also access\n        fields by index:\n\n        >>> (\n        ...     pl.Struct({\"x\": pl.Int64, \"y\": pl.String})\n        ...     .to_dtype_expr()\n        ...     .struct[1]\n        ...     .collect_dtype({})\n        ... )\n        String","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/datatype_expr/struct.py#L6-L42","documentation":"Error \"expected type 'int | str', got {qualified_type_name(item)!r} ({item!r})\" thrown in pola-rs/polars.","triggerScenarios":"Thrown at py-polars/src/polars/datatype_expr/struct.py:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}