@@ -76,29 +76,28 @@ def __init__(
76
76
value_range : Union [Tuple [int , int ], Tuple [float , float ]] = (0 , 100 ),
77
77
) -> None :
78
78
79
- assert (
80
- value_range [0 ] < value_range [1 ]
81
- ), "The minimum value must be less than the maximum value"
79
+ if not (value_range [0 ] < value_range [1 ]):
80
+ raise ValueError ("The minimum value must be less than the maximum value" )
82
81
83
- assert (
84
- size [0 ] > 0 and size [1 ] > 0
85
- ), "The width and the height must be greater than zero"
82
+ if not (size [0 ] > 0 and size [1 ] > 0 ):
83
+ raise ValueError ("The width and the height must be greater than zero" )
86
84
87
- assert (
88
- value_range [0 ] <= value <= value_range [1 ]
89
- ), "The starting value must be within the range of minimum to maximum"
85
+ if not (value_range [0 ] <= value <= value_range [1 ]):
86
+ raise ValueError ("The starting value must be within the range of minimum to maximum" )
90
87
91
88
_edge_size = 2 * margin_size + 2 * border_thickness
92
89
93
- assert _edge_size < size [0 ], (
94
- "The size of the borders and margins combined must be "
95
- "less than the width of the widget"
96
- )
90
+ if not (_edge_size < size [0 ]):
91
+ raise ValueError (
92
+ "The size of the borders and margins combined must be "
93
+ "less than the width of the widget"
94
+ )
97
95
98
- assert _edge_size < size [1 ], (
99
- "The size of the borders and margins combined must be "
100
- "less than the height of the widget"
101
- )
96
+ if not (_edge_size < size [1 ]):
97
+ raise ValueError (
98
+ "The size of the borders and margins combined must be "
99
+ "less than the height of the widget"
100
+ )
102
101
103
102
self ._progress = 0.0
104
103
self ._widget_size = size
@@ -201,9 +200,8 @@ def border_color(self, color: Union[int, Tuple[int, int, int]]) -> None:
201
200
:rtype: None
202
201
"""
203
202
204
- assert (
205
- isinstance (color , int ) or color is None
206
- ), "A color must be represented by a integer value"
203
+ if not (isinstance (color , int ) or color is None ):
204
+ raise TypeError ("A color must be represented by a integer value" )
207
205
208
206
self ._border_color = color
209
207
@@ -285,13 +283,11 @@ def value(self, value: Union[int, float]) -> None:
285
283
:rtype: None
286
284
"""
287
285
288
- assert isinstance (
289
- value , (int , float )
290
- ), "The value to set must be either an integer or a float"
286
+ if not (isinstance (value , (int , float ))):
287
+ raise TypeError ("The value to set must be either an integer or a float" )
291
288
292
- assert (
293
- self .minimum <= value <= self .maximum
294
- ), f"The value must be between minimum ({ self .minimum } ) and maximum ({ self .maximum } )"
289
+ if not (self .minimum <= value <= self .maximum ):
290
+ raise ValueError (f"The value must be between minimum ({ self .minimum } ) and maximum ({ self .maximum } )" )
295
291
296
292
# Save off the previous value, so we can pass it in the
297
293
# call to "Render"
@@ -332,9 +328,11 @@ def progress(self, value: float) -> None:
332
328
:rtype: None
333
329
"""
334
330
335
- assert [isinstance (value , (float , int )), "'progress' must be an int or a float" ]
331
+ if not (isinstance (value , (float , int ))):
332
+ raise TypeError ("'progress' must be an int or a float" )
336
333
337
- assert 0.0 <= value <= 100.0 , "'progress' must be between 0 and 100"
334
+ if not (0.0 <= value <= 100.0 ):
335
+ raise ValueError ("'progress' must be between 0 and 100" )
338
336
339
337
self .value = (self .minimum + (self .maximum - self .minimum )) * (value * 0.01 )
340
338
@@ -449,19 +447,22 @@ def margin_size(self, value: int) -> None:
449
447
:rtype: None
450
448
"""
451
449
452
- assert isinstance (value , int ), "The margin size must be an integer"
450
+ if not (isinstance (value , int )):
451
+ raise TypeError ("The margin size must be an integer" )
453
452
454
453
margin_spacing = (2 * value ) + (2 * self ._border_thickness )
455
454
456
- assert margin_spacing < self .widget_width , (
457
- "The size of the borders and margins combined can total the same or more"
458
- "than the widget's width."
459
- )
460
-
461
- assert margin_spacing < self .widget_height , (
462
- "The size of the borders and margins combined can total the same or more"
463
- "than the widget's height."
464
- )
455
+ if not (margin_spacing < self .widget_width ):
456
+ raise ValueError (
457
+ "The size of the borders and margins combined can total the same or more"
458
+ "than the widget's width."
459
+ )
460
+
461
+ if not (margin_spacing < self .widget_height ):
462
+ raise ValueError (
463
+ "The size of the borders and margins combined can total the same or more"
464
+ "than the widget's height."
465
+ )
465
466
466
467
self ._margin_size = value
467
468
self ._set_progress (self ._progress ) # For a render pass
0 commit comments