mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Remove a couple of annoying type errors
The code worked and was fine, but pyright was getting upset at the typing. This clears that up.
This commit is contained in:
@@ -17,6 +17,7 @@ from ._toggle_button import ToggleButton
|
||||
|
||||
SelectionType = TypeVar("SelectionType")
|
||||
"""The type for the value of a `Selection`"""
|
||||
|
||||
MessageSelectionType = TypeVar("MessageSelectionType")
|
||||
"""The type for the value of a `SelectionList` message"""
|
||||
|
||||
@@ -201,9 +202,13 @@ class SelectionList(Generic[SelectionType], OptionList):
|
||||
An instance of a `Selection`.
|
||||
"""
|
||||
if len(selection) == 3:
|
||||
label, value, selected = selection
|
||||
label, value, selected = cast(
|
||||
tuple[TextType, SelectionType, bool], selection
|
||||
)
|
||||
elif len(selection) == 2:
|
||||
label, value, selected = (*selection, False)
|
||||
label, value, selected = cast(
|
||||
tuple[TextType, SelectionType, bool], (*selection, False)
|
||||
)
|
||||
else:
|
||||
# TODO: Proper error.
|
||||
raise TypeError("Wrong number of values for a selection.")
|
||||
|
||||
Reference in New Issue
Block a user