{"record":{"id":"60f8b681d0254284","repo":"slint-ui/slint","slug":"type-self-name-does-not-support-removing-rows","errorCode":null,"errorMessage":"{type(self).__name__} does not support removing rows","messagePattern":"(.+?) does not support removing rows","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"api/python/slint/slint/models.py","lineNumber":69,"sourceCode":"        ...\n\n    @abstractmethod\n    def row_data(self, row: int) -> T | None:\n        \"\"\"Returns the data for the given row.\n        Re-implement this method in a sub-class to provide the data.\"\"\"\n        ...\n\n    def push_row(self, value: T) -> None:\n        \"\"\"Add a new row to the model with the provided value.\n        The default implementation calls `insert_row` with the row count.\"\"\"\n        self.insert_row(self.row_count(), value)\n\n    def remove_row(self, row: int) -> None:\n        \"\"\"Remove the row at the given index.\n        Raises an exception when the model rejects the modification.\n        The default implementation raises NotImplementedError. A model that\n        supports removing rows should also call `notify_row_removed`.\"\"\"\n        raise NotImplementedError(\n            f\"{type(self).__name__} does not support removing rows\"\n        )\n\n    def insert_row(self, row: int, value: T) -> None:\n        \"\"\"Insert a new row at the given index.\n        Raises an exception when the model rejects the modification.\n        The default implementation raises NotImplementedError. A model that\n        supports inserting rows should also call `notify_row_added`.\"\"\"\n        raise NotImplementedError(\n            f\"{type(self).__name__} does not support inserting rows\"\n        )\n\n    def notify_row_changed(self, row: int) -> None:\n        \"\"\"Call this method from a sub-class to notify the views that a row has changed.\"\"\"\n        super().notify_row_changed(row)\n\n    def notify_row_removed(self, row: int, count: int) -> None:\n        \"\"\"Call this method from a sub-class to notify the views that","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/api/python/slint/slint/models.py#L51-L87","documentation":"The base Model class's remove_row default implementation raises NotImplementedError because a generic model cannot delete rows. Subclasses must override remove_row (and call notify_row_removed) to support row deletion.","triggerScenarios":"Calling model.remove_row(index) on a model instance (or subclass that did not override remove_row), e.g. on a Model or ListModel-like object that only implements read access.","commonSituations":"Passing a read-only or custom model to UI code (ListView with swipe-to-delete) that invokes remove_row; forgetting to override remove_row when subclassing slint.Model.","solutions":["Use a model that supports deletion, e.g. slint.ListModel, which implements remove_row.","In a custom model subclass, override remove_row to delete the backing data and call self.notify_row_removed(row, 1).","Restructure the UI to not delete rows from this model if mutation is intentionally unsupported."],"exampleFix":"# before\nclass MyModel(slint.Model):\n    def row_count(self): return len(self.data)\n\n# after\nclass MyModel(slint.Model):\n    def row_count(self): return len(self.data)\n    def remove_row(self, row):\n        del self.data[row]\n        self.notify_row_removed(row, 1)","handlingStrategy":"type-guard","validationCode":"def supports_remove(model):\n    return type(model).remove_row is not slint.Model.remove_row","typeGuard":"def supports_remove(model):\n    return isinstance(model, slint.ListModel) or overrides(model, \"remove_row\")","tryCatchPattern":"try:\n    model.remove_row(idx)\nexcept NotImplementedError:\n    rebuild_model_without(idx)","preventionTips":["Prefer slint.ListModel for mutable collections.","Override remove_row + notify_row_removed whenever a custom model can delete."],"tags":["python","model","not-implemented","unsupported-operation"],"backgroundTag":"method-not-implemented","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}