{"record":{"id":"6357f12fb16afcd5","repo":"Textualize/textual","slug":"only-selection-or-a-prompt-value-tuple-is-supporte","errorCode":null,"errorMessage":"Only Selection or a prompt/value tuple is supported in SelectionList","messagePattern":"Only Selection or a prompt/value tuple is supported in SelectionList","errorType":"exception","errorClass":"SelectionError","httpStatus":null,"severity":"error","filePath":"src/textual/widgets/_selection_list.py","lineNumber":670,"sourceCode":"        # things like a separator, or a base Option, being passed in. So we\n        # extend the types of accepted items to keep mypy and friends happy,\n        # but then we runtime check that we've been given sensible types (in\n        # this case the supported tuple values).\n        cleaned_options: list[Selection[SelectionType]] = []\n        for item in items:\n            if isinstance(item, tuple):\n                cleaned_options.append(\n                    self._make_selection(\n                        cast(\n                            \"tuple[ContentText, SelectionType] | tuple[ContentText, SelectionType, bool]\",\n                            item,\n                        )\n                    )\n                )\n            elif isinstance(item, Selection):\n                cleaned_options.append(self._make_selection(item))\n            else:\n                raise SelectionError(\n                    \"Only Selection or a prompt/value tuple is supported in SelectionList\"\n                )\n\n        # Add the new items to the value mappings.\n        self._values.update(\n            {\n                option.value: index\n                for index, option in enumerate(cleaned_options, start=self.option_count)\n            }\n        )\n\n        return super().add_options(cleaned_options)\n\n    def add_option(\n        self,\n        item: (\n            OptionListContent\n            | Selection","sourceCodeStart":652,"sourceCodeEnd":688,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/widgets/_selection_list.py#L652-L688","documentation":"Raised by SelectionList.add_options when an item in the sequence is neither a Selection instance nor a tuple (tuples are forwarded to _make_selection). Any other type — a string, list, or arbitrary object — is rejected with SelectionError.","triggerScenarios":"SelectionList(['just a string']) or add_options([['prompt', True]]) (list instead of tuple), or passing Option objects meant for OptionList.","commonSituations":"Mixing up OptionList and SelectionList APIs, passing plain strings for simple lists, or lists-of-lists from JSON instead of tuples.","solutions":["Convert each item to a Selection or a (prompt, value[, state]) tuple.","Use add_selection(...) APIs for single items where applicable.","For string-only lists use SelectionList([(s, s) for s in strings])."],"exampleFix":"# before\nSelectionList(['apples', 'pears'])\n# after\nSelectionList([('apples', 'apples'), ('pears', 'pears')])","handlingStrategy":"type-guard","validationCode":"items = [Selection(s, s) if isinstance(s, str) else s for s in items]","typeGuard":"from textual.widgets.selection_list import Selection\ndef is_selection_item(x) -> bool: return isinstance(x, (Selection, tuple))","tryCatchPattern":null,"preventionTips":["Don't reuse OptionList Option objects in SelectionList","Normalize strings to (prompt, value) tuples"],"tags":["selection-list","type-mismatch","textual"],"backgroundTag":"invalid-option-type","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}