{"record":{"id":"1cfe2f5c790ff63b","repo":"reflex-dev/reflex","slug":"annotation-of-the-computed-var-assigned-to-the-col","errorCode":null,"errorMessage":"Annotation of the computed var assigned to the column field should be provided.","messagePattern":"Annotation of the computed var assigned to the column field should be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-gridjs/src/reflex_components_gridjs/datatable.py","lineNumber":76,"sourceCode":"        Raises:\n            ValueError: If a pandas dataframe is passed in and columns are also provided.\n        \"\"\"\n        data = props.get(\"data\")\n        columns = props.get(\"columns\")\n\n        # The annotation should be provided if data is a computed var. We need this to know how to\n        # render pandas dataframes.\n        if is_computed_var(data) and data._var_type == Any:\n            msg = \"Annotation of the computed var assigned to the data field should be provided.\"\n            raise ValueError(msg)\n\n        if (\n            columns is not None\n            and is_computed_var(columns)\n            and columns._var_type == Any\n        ):\n            msg = \"Annotation of the computed var assigned to the column field should be provided.\"\n            raise ValueError(msg)\n\n        # If data is a pandas dataframe and columns are provided throw an error.\n        if (\n            types.is_dataframe(type(data))\n            or (isinstance(data, Var) and types.is_dataframe(data._var_type))\n        ) and columns is not None:\n            msg = \"Cannot pass in both a pandas dataframe and columns to the data_table component.\"\n            raise ValueError(msg)\n\n        # If data is a list and columns are not provided, throw an error\n        if (\n            (isinstance(data, Var) and types.typehint_issubclass(data._var_type, list))\n            or isinstance(data, list)\n        ) and columns is None:\n            msg = \"column field should be specified when the data field is a list type\"\n            raise ValueError(msg)\n\n        # Create the component.","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-gridjs/src/reflex_components_gridjs/datatable.py#L58-L94","documentation":"Same requirement as the data field, but for columns: if columns is a computed var with no annotation (type Any), data_table cannot determine its structure and raises this.","triggerScenarios":"Passing an unannotated @rx.var-computed columns to rx.data_table(...): @rx.var def get_columns(self): return [...] with no return type.","commonSituations":"Generating column definitions dynamically (e.g. from user config) without adding a return annotation.","solutions":["Annotate the columns computed var with its concrete type, e.g. -> list[dict[str, Any]] or -> list[rx.gridjs.datatable.Column]","Alternatively pass columns as a static list"],"exampleFix":"# before\n@rx.var\ndef cols(self):\n    return [{\"name\": c} for c in self.headers]\n# after\n@rx.var\ndef cols(self) -> list[dict[str, Any]]:\n    return [{\"name\": c} for c in self.headers]","handlingStrategy":"type-guard","validationCode":"if columns is not None and is_computed_var(columns) and columns._var_type is Any:\n    raise ValueError('annotate columns computed var')  # fail fast with your own context","typeGuard":"def columns_var_ok(columns: Any) -> bool:\n    return columns is None or not (is_computed_var(columns) and columns._var_type is Any)","tryCatchPattern":null,"preventionTips":["Annotate computed vars: -> list[dict[str, Any]]","Prefer static column lists when possible"],"tags":["reflex","gridjs","computed-var","type-annotation"],"backgroundTag":"missing-type-annotation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}