flet 0.70.0.dev5774__py3-none-any.whl → 0.70.0.dev5835__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flet might be problematic. Click here for more details.

Files changed (96) hide show
  1. flet/__init__.py +32 -4
  2. flet/components/__init__.py +0 -0
  3. flet/components/component.py +346 -0
  4. flet/components/component_decorator.py +24 -0
  5. flet/components/component_owned.py +22 -0
  6. flet/components/hooks/__init__.py +0 -0
  7. flet/components/hooks/hook.py +12 -0
  8. flet/components/hooks/use_callback.py +28 -0
  9. flet/components/hooks/use_context.py +91 -0
  10. flet/components/hooks/use_effect.py +104 -0
  11. flet/components/hooks/use_memo.py +52 -0
  12. flet/components/hooks/use_state.py +58 -0
  13. flet/components/memo.py +34 -0
  14. flet/components/observable.py +269 -0
  15. flet/components/public_utils.py +10 -0
  16. flet/components/utils.py +85 -0
  17. flet/controls/base_control.py +34 -10
  18. flet/controls/base_page.py +44 -40
  19. flet/controls/context.py +22 -1
  20. flet/controls/control.py +12 -6
  21. flet/controls/control_event.py +19 -2
  22. flet/controls/core/animated_switcher.py +3 -2
  23. flet/controls/core/autofill_group.py +6 -2
  24. flet/controls/core/column.py +5 -0
  25. flet/controls/core/dismissible.py +12 -10
  26. flet/controls/core/drag_target.py +20 -10
  27. flet/controls/core/draggable.py +9 -9
  28. flet/controls/core/icon.py +16 -12
  29. flet/controls/core/interactive_viewer.py +24 -23
  30. flet/controls/core/pagelet.py +3 -2
  31. flet/controls/core/reorderable_draggable.py +3 -2
  32. flet/controls/core/row.py +5 -0
  33. flet/controls/core/safe_area.py +3 -2
  34. flet/controls/core/text_span.py +5 -3
  35. flet/controls/core/view.py +6 -6
  36. flet/controls/core/window_drag_area.py +3 -2
  37. flet/controls/cupertino/cupertino_action_sheet.py +10 -5
  38. flet/controls/cupertino/cupertino_action_sheet_action.py +3 -4
  39. flet/controls/cupertino/cupertino_activity_indicator.py +4 -3
  40. flet/controls/cupertino/cupertino_alert_dialog.py +6 -3
  41. flet/controls/cupertino/cupertino_button.py +6 -5
  42. flet/controls/cupertino/cupertino_context_menu.py +8 -4
  43. flet/controls/cupertino/cupertino_context_menu_action.py +3 -4
  44. flet/controls/cupertino/cupertino_date_picker.py +44 -28
  45. flet/controls/cupertino/cupertino_dialog_action.py +3 -4
  46. flet/controls/cupertino/cupertino_list_tile.py +3 -4
  47. flet/controls/cupertino/cupertino_navigation_bar.py +6 -5
  48. flet/controls/cupertino/cupertino_picker.py +14 -10
  49. flet/controls/cupertino/cupertino_segmented_button.py +6 -5
  50. flet/controls/cupertino/cupertino_slider.py +16 -12
  51. flet/controls/cupertino/cupertino_sliding_segmented_button.py +6 -5
  52. flet/controls/cupertino/cupertino_timer_picker.py +38 -31
  53. flet/controls/id_counter.py +24 -0
  54. flet/controls/material/alert_dialog.py +6 -5
  55. flet/controls/material/app_bar.py +17 -14
  56. flet/controls/material/banner.py +13 -11
  57. flet/controls/material/bottom_app_bar.py +5 -4
  58. flet/controls/material/bottom_sheet.py +5 -4
  59. flet/controls/material/button.py +12 -4
  60. flet/controls/material/chip.py +13 -12
  61. flet/controls/material/circle_avatar.py +17 -13
  62. flet/controls/material/datatable.py +48 -41
  63. flet/controls/material/divider.py +30 -14
  64. flet/controls/material/dropdown.py +5 -3
  65. flet/controls/material/expansion_tile.py +11 -22
  66. flet/controls/material/floating_action_button.py +32 -23
  67. flet/controls/material/icon_button.py +7 -3
  68. flet/controls/material/navigation_rail.py +14 -11
  69. flet/controls/material/outlined_button.py +7 -3
  70. flet/controls/material/progress_bar.py +18 -10
  71. flet/controls/material/radio_group.py +5 -1
  72. flet/controls/material/range_slider.py +13 -13
  73. flet/controls/material/segmented_button.py +21 -17
  74. flet/controls/material/selection_area.py +3 -2
  75. flet/controls/material/slider.py +16 -12
  76. flet/controls/material/snack_bar.py +18 -10
  77. flet/controls/material/switch.py +6 -5
  78. flet/controls/material/tabs.py +18 -14
  79. flet/controls/material/textfield.py +32 -15
  80. flet/controls/material/vertical_divider.py +20 -12
  81. flet/controls/object_patch.py +434 -197
  82. flet/controls/page.py +205 -85
  83. flet/controls/services/haptic_feedback.py +0 -3
  84. flet/controls/services/shake_detector.py +0 -3
  85. flet/messaging/flet_socket_server.py +13 -6
  86. flet/messaging/session.py +103 -10
  87. flet/{controls/session_storage.py → messaging/session_store.py} +2 -2
  88. flet/version.py +1 -1
  89. {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/METADATA +5 -5
  90. {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/RECORD +93 -80
  91. flet/controls/cache.py +0 -87
  92. flet/controls/control_id.py +0 -22
  93. flet/controls/core/state_view.py +0 -60
  94. {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/WHEEL +0 -0
  95. {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/entry_points.txt +0 -0
  96. {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/top_level.txt +0 -0
@@ -26,7 +26,7 @@ class Pagelet(LayoutControl, AdaptiveControl):
26
26
  such as demos and galleries.
27
27
 
28
28
  Raises:
29
- AssertionError: If [`content`][(c).] is not visible.
29
+ ValueError: If [`content`][(c).] is not visible.
30
30
  """
31
31
 
32
32
  content: Control
@@ -104,7 +104,8 @@ class Pagelet(LayoutControl, AdaptiveControl):
104
104
 
105
105
  def before_update(self):
106
106
  super().before_update()
107
- assert self.content.visible, "content must be visible"
107
+ if not self.content.visible:
108
+ raise ValueError("content must be visible")
108
109
 
109
110
  # todo: deprecate show_* in favor of a open/close methods, or page.open/close
110
111
  # Drawer
@@ -13,7 +13,7 @@ class ReorderableDraggable(LayoutControl, AdaptiveControl):
13
13
  event over the given [`content`][(c).] control.
14
14
 
15
15
  Raises:
16
- AssertionError: If [`content`][(c).] is not visible.
16
+ ValueError: If [`content`][(c).] is not visible.
17
17
  """
18
18
 
19
19
  index: int
@@ -29,4 +29,5 @@ class ReorderableDraggable(LayoutControl, AdaptiveControl):
29
29
 
30
30
  def before_update(self):
31
31
  super().before_update()
32
- assert self.content.visible, "content must be visible"
32
+ if not self.content.visible:
33
+ raise ValueError("content must be visible")
flet/controls/core/row.py CHANGED
@@ -68,6 +68,11 @@ class Row(LayoutControl, ScrollableControl, AdaptiveControl):
68
68
  How the runs should be placed in the cross-axis when `wrap=True`.
69
69
  """
70
70
 
71
+ intrinsic_height: bool = False
72
+ """
73
+ If `True`, the Row will be as tall as the tallest child control.
74
+ """
75
+
71
76
  def init(self):
72
77
  super().init()
73
78
  self._internals["host_expanded"] = True
@@ -23,7 +23,7 @@ class SafeArea(LayoutControl, AdaptiveControl):
23
23
  or the safe area padding will be applied.
24
24
 
25
25
  Raises:
26
- AssertionError: If [`content`][(c).] is not visible.
26
+ ValueError: If [`content`][(c).] is not visible.
27
27
  """
28
28
 
29
29
  content: Control
@@ -71,4 +71,5 @@ class SafeArea(LayoutControl, AdaptiveControl):
71
71
 
72
72
  def before_update(self):
73
73
  super().before_update()
74
- assert self.content.visible, "content must be visible"
74
+ if not self.content.visible:
75
+ raise ValueError("content must be visible")
@@ -18,6 +18,9 @@ class TextSpan(Control):
18
18
 
19
19
  For the object to be useful, at least one of [`text`][(c).] or
20
20
  [`spans`][(c).] should be set.
21
+
22
+ Raises:
23
+ ValueError: If [`semantics_label`][(c).] is set when [`text`][(c).] is `None`.
21
24
  """
22
25
 
23
26
  text: Optional[str] = None
@@ -94,6 +97,5 @@ class TextSpan(Control):
94
97
 
95
98
  def before_update(self):
96
99
  super().before_update()
97
- assert not (self.text is None and self.semantics_label is not None), (
98
- "semantics_label can be set only when text is not None"
99
- )
100
+ if self.text is None and self.semantics_label is not None:
101
+ raise ValueError("semantics_label can be set only when text is not None")
@@ -37,12 +37,6 @@ class View(ScrollableControl, LayoutControl):
37
37
  control, so it has a similar behavior and shares same properties.
38
38
  """
39
39
 
40
- route: Optional[str] = None
41
- """
42
- View's route - not currently used by Flet framework, but can be used in a user
43
- program to update [`Page.route`][flet.] when a view popped.
44
- """
45
-
46
40
  controls: list[BaseControl] = field(default_factory=list)
47
41
  """
48
42
  A list of controls to display.
@@ -71,6 +65,12 @@ class View(ScrollableControl, LayoutControl):
71
65
  ///
72
66
  """
73
67
 
68
+ route: Optional[str] = field(default_factory=lambda: "/")
69
+ """
70
+ View's route - not currently used by Flet framework, but can be used in a user
71
+ program to update [`Page.route`][flet.Page.route] when a view popped.
72
+ """
73
+
74
74
  appbar: Optional[Union[AppBar, CupertinoAppBar]] = None
75
75
  """
76
76
  An [`AppBar`][flet.] control to display at the top of
@@ -15,7 +15,7 @@ class WindowDragArea(LayoutControl):
15
15
  title bar on the [`content`][(c).] control.
16
16
 
17
17
  Raises:
18
- AssertionError: If [`content`][(c).] is not visible.
18
+ ValueError: If [`content`][(c).] is not visible.
19
19
  """
20
20
 
21
21
  content: Control
@@ -54,4 +54,5 @@ class WindowDragArea(LayoutControl):
54
54
 
55
55
  def before_update(self):
56
56
  super().before_update()
57
- assert self.content.visible, "content must be visible"
57
+ if not self.content.visible:
58
+ raise ValueError("content must be visible")
@@ -15,6 +15,10 @@ class CupertinoActionSheet(LayoutControl):
15
15
 
16
16
  Action sheets are generally used to give the user a choice between
17
17
  two or more choices for the current context.
18
+
19
+ Raises:
20
+ ValueError: If none of [`actions`][(c).], [`title`][(c).], [`message`][(c).],
21
+ or [`cancel`][(c).] are provided.
18
22
  """
19
23
 
20
24
  title: Optional[StrOrControl] = None
@@ -48,12 +52,13 @@ class CupertinoActionSheet(LayoutControl):
48
52
 
49
53
  def before_update(self):
50
54
  super().before_update()
51
- assert (
55
+ if not (
52
56
  self.actions is not None
53
57
  or self.title is not None
54
58
  or self.message is not None
55
59
  or self.cancel is not None
56
- ), (
57
- "This action sheet must have a non-None value for at least one of the "
58
- "following arguments: `actions`, `title`, `message`, or `cancel`"
59
- )
60
+ ):
61
+ raise ValueError(
62
+ "This action sheet must have a non-None value for at least one of the "
63
+ "following arguments: `actions`, `title`, `message`, or `cancel`"
64
+ )
@@ -14,7 +14,7 @@ class CupertinoActionSheetAction(LayoutControl):
14
14
  An action button typically used in a CupertinoActionSheet.
15
15
 
16
16
  Raises:
17
- AssertionError: If [`content`][(c).] is neither a string nor a visible Control.
17
+ ValueError: If [`content`][(c).] is neither a string nor a visible Control.
18
18
  """
19
19
 
20
20
  content: StrOrControl
@@ -44,6 +44,5 @@ class CupertinoActionSheetAction(LayoutControl):
44
44
 
45
45
  def before_update(self):
46
46
  super().before_update()
47
- assert isinstance(self.content, str) or self.content.visible, (
48
- "content must be a string or a visible Control"
49
- )
47
+ if not (isinstance(self.content, str) or self.content.visible):
48
+ raise ValueError("content must be a string or a visible Control")
@@ -36,6 +36,7 @@ class CupertinoActivityIndicator(LayoutControl):
36
36
 
37
37
  def before_update(self):
38
38
  super().before_update()
39
- assert self.radius > 0.0, (
40
- f"radius must be strictly greater than 0.0, got {self.radius}"
41
- )
39
+ if self.radius <= 0.0:
40
+ raise ValueError(
41
+ f"radius must be strictly greater than 0.0, got {self.radius}"
42
+ )
@@ -60,9 +60,12 @@ class CupertinoAlertDialog(DialogControl):
60
60
 
61
61
  def before_update(self):
62
62
  super().before_update()
63
- assert (
63
+ if not (
64
64
  (isinstance(self.title, str) or self.title.visible)
65
65
  or (self.content and self.content.visible)
66
66
  or any(a.visible for a in self.actions)
67
- ), "AlertDialog has nothing to display. Provide at minimum one of the "
68
- "following: title, content, actions"
67
+ ):
68
+ raise ValueError(
69
+ "AlertDialog has nothing to display. Provide at minimum one of the "
70
+ "following: title, content, actions"
71
+ )
@@ -33,7 +33,7 @@ class CupertinoButton(LayoutControl):
33
33
  An iOS-style button.
34
34
 
35
35
  Raises:
36
- AssertionError: If [`opacity_on_click`][(c).] is not between `0.0`
36
+ ValueError: If [`opacity_on_click`][(c).] is not between `0.0`
37
37
  and `1.0` inclusive.
38
38
  """
39
39
 
@@ -158,10 +158,11 @@ class CupertinoButton(LayoutControl):
158
158
 
159
159
  def before_update(self):
160
160
  super().before_update()
161
- assert 0 <= self.opacity_on_click <= 1, (
162
- "opacity_on_click must be between 0 and 1 inclusive, "
163
- f"got {self.opacity_on_click}"
164
- )
161
+ if not (0 <= self.opacity_on_click <= 1):
162
+ raise ValueError(
163
+ "opacity_on_click must be between 0 and 1 inclusive, "
164
+ f"got {self.opacity_on_click}"
165
+ )
165
166
 
166
167
  async def focus(self):
167
168
  await self._invoke_method("focus")
@@ -9,6 +9,10 @@ __all__ = ["CupertinoContextMenu"]
9
9
  class CupertinoContextMenu(AdaptiveControl):
10
10
  """
11
11
  A full-screen modal route that opens up when the [`content`][(c).] is long-pressed.
12
+
13
+ Raises:
14
+ ValueError: If [`content`][(c).] is not visible.
15
+ ValueError: If [`actions`][(c).] does not contain at least one visible action.
12
16
  """
13
17
 
14
18
  content: Control
@@ -38,7 +42,7 @@ class CupertinoContextMenu(AdaptiveControl):
38
42
 
39
43
  def before_update(self):
40
44
  super().before_update()
41
- assert self.content.visible, "content must be visible"
42
- assert any(a.visible for a in self.actions), (
43
- "at least one action must be visible"
44
- )
45
+ if not self.content.visible:
46
+ raise ValueError("content must be visible")
47
+ if not any(a.visible for a in self.actions):
48
+ raise ValueError("at least one action must be visible")
@@ -16,7 +16,7 @@ class CupertinoContextMenuAction(AdaptiveControl):
16
16
  Typically used as a child of [`CupertinoContextMenu.actions`][flet.].
17
17
 
18
18
  Raises:
19
- AssertionError: If [`content`][(c).] is neither a string nor a visible Control.
19
+ ValueError: If [`content`][(c).] is neither a string nor a visible Control.
20
20
  """
21
21
 
22
22
  content: StrOrControl
@@ -46,6 +46,5 @@ class CupertinoContextMenuAction(AdaptiveControl):
46
46
 
47
47
  def before_update(self):
48
48
  super().before_update()
49
- assert isinstance(self.content, str) or self.content.visible, (
50
- "content must be a string or a visible Control"
51
- )
49
+ if not (isinstance(self.content, str) or self.content.visible):
50
+ raise ValueError("content must be a string or a visible Control")
@@ -34,6 +34,15 @@ class CupertinoDatePickerDateOrder(Enum):
34
34
  class CupertinoDatePicker(LayoutControl):
35
35
  """
36
36
  An iOS-styled date picker.
37
+
38
+ Raises:
39
+ ValueError: If [`item_extent`][(c).] is not strictly greater than `0`.
40
+ ValueError: If [`minute_interval`][(c).] is not a positive integer
41
+ factor of `60`.
42
+ ValueError: If [`value`][(c).] is before [`first_date`][(c).] or
43
+ after [`last_date`][(c).].
44
+ ValueError: If [`value`][(c).] year is less than [`minimum_year`][(c).] or
45
+ greater than [`maximum_year`][(c).].
37
46
  """
38
47
 
39
48
  value: DateTimeValue = field(default_factory=lambda: datetime.now())
@@ -159,21 +168,23 @@ class CupertinoDatePicker(LayoutControl):
159
168
  else:
160
169
  value = self.value
161
170
 
162
- assert self.item_extent > 0, (
163
- f"item_extent must be strictly greater than 0, got {self.item_extent}"
164
- )
165
- assert self.minute_interval > 0 and 60 % self.minute_interval == 0, (
166
- f"minute_interval must be a positive integer factor of 60, "
167
- f"got {self.minute_interval}"
168
- )
171
+ if self.item_extent <= 0:
172
+ raise ValueError(
173
+ f"item_extent must be strictly greater than 0, got {self.item_extent}"
174
+ )
175
+ if not (self.minute_interval > 0 and 60 % self.minute_interval == 0):
176
+ raise ValueError(
177
+ f"minute_interval must be a positive integer factor of 60, "
178
+ f"got {self.minute_interval}"
179
+ )
169
180
 
170
181
  if self.date_picker_mode == CupertinoDatePickerMode.DATE_AND_TIME:
171
- if self.first_date:
172
- assert value >= self.first_date, (
182
+ if self.first_date and value < self.first_date:
183
+ raise ValueError(
173
184
  f"value ({value}) can't be before first_date ({self.first_date})"
174
185
  )
175
- if self.last_date:
176
- assert value <= self.last_date, (
186
+ if self.last_date and value > self.last_date:
187
+ raise ValueError(
177
188
  f"value ({value}) can't be after last_date ({self.last_date})"
178
189
  )
179
190
 
@@ -181,34 +192,39 @@ class CupertinoDatePicker(LayoutControl):
181
192
  CupertinoDatePickerMode.DATE,
182
193
  CupertinoDatePickerMode.MONTH_YEAR,
183
194
  ]:
184
- assert 1 <= self.minimum_year <= value.year, (
185
- f"value.year ({value.year}) can't be less than minimum_year "
186
- )
187
- f"({self.minimum_year})"
195
+ if not (1 <= self.minimum_year <= value.year):
196
+ raise ValueError(
197
+ f"value.year ({value.year}) can't be less than minimum_year "
198
+ f"({self.minimum_year})"
199
+ )
188
200
 
189
- if self.maximum_year:
190
- assert value.year <= self.maximum_year, (
201
+ if self.maximum_year and value.year > self.maximum_year:
202
+ raise ValueError(
191
203
  f"value.year ({value.year}) can't be greater than maximum_year "
204
+ f"({self.maximum_year})"
192
205
  )
193
- f"({self.maximum_year})"
194
206
 
195
- if self.first_date:
196
- assert value >= self.first_date, (
207
+ if self.first_date and value < self.first_date:
208
+ raise ValueError(
197
209
  f"value ({value}) can't be before first_date ({self.first_date})"
198
210
  )
199
211
 
200
- if self.last_date:
201
- assert value <= self.last_date, (
212
+ if self.last_date and value > self.last_date:
213
+ raise ValueError(
202
214
  f"value ({value}) can't be after last_date ({self.last_date})"
203
215
  )
204
216
 
205
- if self.date_picker_mode != CupertinoDatePickerMode.DATE:
206
- assert not self.show_day_of_week, (
217
+ if (
218
+ self.date_picker_mode != CupertinoDatePickerMode.DATE
219
+ and self.show_day_of_week
220
+ ):
221
+ raise ValueError(
207
222
  "show_day_of_week is only supported when date_picker_mode is "
208
223
  "CupertinoDatePickerMode.DATE"
209
224
  )
210
225
 
211
- assert value.minute % self.minute_interval == 0, (
212
- f"value.minute ({value.minute}) must be divisible by minute_interval "
213
- )
214
- f"({self.minute_interval})"
226
+ if value.minute % self.minute_interval != 0:
227
+ raise ValueError(
228
+ f"value.minute ({value.minute}) must be divisible by minute_interval "
229
+ f"({self.minute_interval})"
230
+ )
@@ -17,7 +17,7 @@ class CupertinoDialogAction(Control):
17
17
  Typically used as a child of [`CupertinoAlertDialog.actions`][flet.].
18
18
 
19
19
  Raises:
20
- AssertionError: If [`content`][(c).] is neither a string nor a visible Control.
20
+ ValueError: If [`content`][(c).] is neither a string nor a visible Control.
21
21
  """
22
22
 
23
23
  content: StrOrControl
@@ -57,6 +57,5 @@ class CupertinoDialogAction(Control):
57
57
 
58
58
  def before_update(self):
59
59
  super().before_update()
60
- assert isinstance(self.content, str) or self.content.visible, (
61
- "content must be a string or a visible Control"
62
- )
60
+ if not (isinstance(self.content, str) or self.content.visible):
61
+ raise ValueError("content must be a string or a visible Control")
@@ -23,7 +23,7 @@ class CupertinoListTile(LayoutControl):
23
23
  Can also serve as a cupertino equivalent of the Material [`ListTile`][flet.].
24
24
 
25
25
  Raises:
26
- AssertionError: If [`title`][(c).] is neither a string nor a visible Control.
26
+ ValueError: If [`title`][(c).] is neither a string nor a visible Control.
27
27
  """
28
28
 
29
29
  title: StrOrControl
@@ -120,6 +120,5 @@ class CupertinoListTile(LayoutControl):
120
120
 
121
121
  def before_update(self):
122
122
  super().before_update()
123
- assert isinstance(self.title, str) or self.title.visible, (
124
- "title must be a string or a visible Control"
125
- )
123
+ if not (isinstance(self.title, str) or self.title.visible):
124
+ raise ValueError("title must be a string or a visible Control")
@@ -23,7 +23,7 @@ class CupertinoNavigationBar(LayoutControl):
23
23
  destinations in an app.
24
24
 
25
25
  Raises:
26
- AssertionError: If [`destinations`][(c).] does not contain at least two visible
26
+ ValueError: If [`destinations`][(c).] does not contain at least two visible
27
27
  [`NavigationBarDestination`][flet.]s.
28
28
  IndexError: If [`selected_index`][(c).] is out of range.
29
29
  """
@@ -80,10 +80,11 @@ class CupertinoNavigationBar(LayoutControl):
80
80
  def before_update(self):
81
81
  super().before_update()
82
82
  visible_destinations_count = len([d for d in self.destinations if d.visible])
83
- assert visible_destinations_count >= 2, (
84
- f"destinations must contain at minimum two visible controls, "
85
- f"got {visible_destinations_count}"
86
- )
83
+ if visible_destinations_count < 2:
84
+ raise ValueError(
85
+ f"destinations must contain at minimum two visible controls, "
86
+ f"got {visible_destinations_count}"
87
+ )
87
88
  if not (0 <= self.selected_index < visible_destinations_count):
88
89
  raise IndexError(
89
90
  f"selected_index ({self.selected_index}) is out of range. "
@@ -20,7 +20,7 @@ class CupertinoPicker(LayoutControl):
20
20
  An iOS-styled picker.
21
21
 
22
22
  Raises:
23
- AssertionError: If [`item_extent`][(c).], [`squeeze`][(c).],
23
+ ValueError: If [`item_extent`][(c).], [`squeeze`][(c).],
24
24
  or [`magnification`][(c).] is not strictly greater than `0.0`.
25
25
  """
26
26
 
@@ -104,12 +104,16 @@ class CupertinoPicker(LayoutControl):
104
104
 
105
105
  def before_update(self):
106
106
  super().before_update()
107
- assert self.squeeze > 0.0, (
108
- f"squeeze must be strictly greater than 0.0, got {self.squeeze}"
109
- )
110
- assert self.magnification > 0.0, (
111
- f"magnification must be strictly greater than 0.0, got {self.magnification}"
112
- )
113
- assert self.item_extent > 0.0, (
114
- f"item_extent must be strictly greater than 0.0, got {self.item_extent}"
115
- )
107
+ if self.squeeze <= 0.0:
108
+ raise ValueError(
109
+ f"squeeze must be strictly greater than 0.0, got {self.squeeze}"
110
+ )
111
+ if self.magnification <= 0.0:
112
+ raise ValueError(
113
+ f"magnification must be strictly greater than 0.0, "
114
+ f"got {self.magnification}"
115
+ )
116
+ if self.item_extent <= 0.0:
117
+ raise ValueError(
118
+ f"item_extent must be strictly greater than 0.0, got {self.item_extent}"
119
+ )
@@ -16,7 +16,7 @@ class CupertinoSegmentedButton(LayoutControl):
16
16
  An iOS-style segmented button.
17
17
 
18
18
  Raises:
19
- AssertionError: If [`controls`][(c).] does not contain at least two visible
19
+ ValueError: If [`controls`][(c).] does not contain at least two visible
20
20
  controls.
21
21
  IndexError: If [`selected_index`][(c).] is out of range.
22
22
  """
@@ -88,10 +88,11 @@ class CupertinoSegmentedButton(LayoutControl):
88
88
  def before_update(self):
89
89
  super().before_update()
90
90
  visible_controls_count = len([c for c in self.controls if c.visible])
91
- assert visible_controls_count >= 2, (
92
- f"controls must contain at minimum two visible Controls, "
93
- f"got {visible_controls_count}"
94
- )
91
+ if visible_controls_count < 2:
92
+ raise ValueError(
93
+ f"controls must contain at minimum two visible Controls, "
94
+ f"got {visible_controls_count}"
95
+ )
95
96
  if not (0 <= self.selected_index < visible_controls_count):
96
97
  raise IndexError(
97
98
  f"selected_index ({self.selected_index}) is out of range. "
@@ -24,9 +24,9 @@ class CupertinoSlider(LayoutControl):
24
24
  setting changes.
25
25
 
26
26
  Raises:
27
- AssertionError: If [`min`][(c).] is greater than or equal to [`max`][(c).].
28
- AssertionError: If [`min`][(c).] is greater than or equal to [`value`][(c).].
29
- AssertionError: If [`max`][(c).] is less than or equal to [`value`][(c).].
27
+ ValueError: If [`min`][(c).] is greater than [`max`][(c).].
28
+ ValueError: If [`value`][(c).] is less than [`min`][(c).].
29
+ ValueError: If [`value`][(c).] is greater than [`max`][(c).].
30
30
  """
31
31
 
32
32
  value: Optional[Number] = None
@@ -102,12 +102,16 @@ class CupertinoSlider(LayoutControl):
102
102
  def before_update(self):
103
103
  super().before_update()
104
104
  self.value = self.value if self.value is not None else self.min
105
- assert self.min <= self.max, (
106
- f"min ({self.min}) must be less than or equal to max ({self.max})"
107
- )
108
- assert self.value is None or (self.value >= self.min), (
109
- f"value ({self.value}) must be greater than or equal to min ({self.min})"
110
- )
111
- assert self.value is None or (self.value <= self.max), (
112
- f"value ({self.value}) must be less than or equal to max ({self.max})"
113
- )
105
+ if self.min > self.max:
106
+ raise ValueError(
107
+ f"min ({self.min}) must be less than or equal to max ({self.max})"
108
+ )
109
+ if self.value is not None and self.value < self.min:
110
+ raise ValueError(
111
+ f"value ({self.value}) must be greater than or "
112
+ f"equal to min ({self.min})"
113
+ )
114
+ if self.value is not None and self.value > self.max:
115
+ raise ValueError(
116
+ f"value ({self.value}) must be less than or equal to max ({self.max})"
117
+ )
@@ -20,7 +20,7 @@ class CupertinoSlidingSegmentedButton(LayoutControl):
20
20
  A cupertino sliding segmented button.
21
21
 
22
22
  Raises:
23
- AssertionError: If [`controls`][(c).] does not contain at least two
23
+ ValueError: If [`controls`][(c).] does not contain at least two
24
24
  visible controls.
25
25
  IndexError: If [`selected_index`][(c).] is out of range.
26
26
  """
@@ -78,10 +78,11 @@ class CupertinoSlidingSegmentedButton(LayoutControl):
78
78
  def before_update(self):
79
79
  super().before_update()
80
80
  visible_controls_count = len([c for c in self.controls if c.visible])
81
- assert visible_controls_count >= 2, (
82
- f"controls must contain at minimum two visible Controls, "
83
- f"got {visible_controls_count}"
84
- )
81
+ if visible_controls_count < 2:
82
+ raise ValueError(
83
+ f"controls must contain at minimum two visible Controls, "
84
+ f"got {visible_controls_count}"
85
+ )
85
86
  if not (0 <= self.selected_index < visible_controls_count):
86
87
  raise IndexError(
87
88
  f"selected_index ({self.selected_index}) is out of range. "