Skip to content

Commit 045be27

Browse files
committed
Fix MultipleChoiceItem validation and update choices to tuple
1 parent 1b78291 commit 045be27

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

doc/release_notes/release_3.14.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
🛠️ Bug fixes:
66

77
* **Old QtPy compatibility**: Fixed `ImportError` when using QtPy < 2.0.0 (guidata supports QtPy >= 1.9) — the `PYSIDE6` constant was not available before QtPy 2.0.0
8+
* **MultipleChoiceItem validation**: Fixed `DataItemValidationError` when accepting a dialog containing a `MultipleChoiceItem` with validation enabled — the widget was passing a list instead of the expected tuple, causing a validation failure when closing the dialog
89

910
## guidata Version 3.14.1 ##
1011

guidata/dataset/dataitems.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,9 +1242,9 @@ def check_value(self, value: str, raise_exception: bool = False) -> bool:
12421242
"""Override DataItem method"""
12431243
if not self.get_prop("data", "check_value", True):
12441244
return True
1245-
if not isinstance(value, tuple):
1245+
if not isinstance(value, (tuple, list)):
12461246
if raise_exception:
1247-
raise ValueError(f"Invalid value '{value}' (expecting tuple)")
1247+
raise ValueError(f"Invalid value '{value}' (expecting tuple or list)")
12481248
return False
12491249
for val in value:
12501250
if val not in [v for v, _k, _i in self.get_prop("data", "choices", [])]:

guidata/dataset/qtitemwidgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ def get(self) -> None:
12971297
def set(self) -> None:
12981298
"""Update data item value from widget contents"""
12991299
_choices = self.item.get_prop_value("data", "choices")
1300-
choices = [_choices[i][0] for i in self.value()]
1300+
choices = tuple(_choices[i][0] for i in self.value())
13011301
self.item.set(choices)
13021302

13031303
def value(self) -> list[int]:

0 commit comments

Comments
 (0)