fix: add set_options to SelectionList
threw me off when this happened to rovr, because the self._selected never got cleared when set_options was used instead of clear_options + add_options
Please review the following checklist.
- [x] Docstrings on all new or modified functions / classes
- [ ] Updated documentation
- [ ] Updated CHANGELOG.md (where appropriate)
Are you sure this is correct? You can build a
SelectionListwith tuples or Selection objects, but here it looks like you're trying to use SelectionType?
not really sure which one to use, given that OptionList's set_option method only takes in an Iterable OptionListContent
I'm confused, Did you check your code actually worked, or just throw the PR over the wall?
The general code worked, but I'm not sure about which class to use as the type hint for the function
Sorry, I think I understand the problem now.
I thought the signature would just be similar to the SelectionList.add_options method:
https://github.com/Textualize/textual/blob/422852a1b74f97fa7770afedd8ae917cb0bde66c/src/textual/widgets/_selection_list.py#L629-L637
But of course this doesn't satisfy mypy and friends for super().set_options(options).
I realise now that I overlooked that this actually ends up calling SelectionList.add_options. Repeating the same runtime checks in both set_option and add_options would definitely be "sort of sub-optimal"!