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