Skip to content

Commit 0a9e9dd

Browse files
committed
Merge remote-tracking branch 'Adafruit/master' into progressbar_accelerometer
2 parents 442483f + c931094 commit 0a9e9dd

File tree

5 files changed

+81
-41
lines changed

5 files changed

+81
-41
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2021 Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
Thank you for contributing! Before you submit a pull request, please read the following.
6+
7+
Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://circuitpython.readthedocs.io/en/latest/docs/design_guide.html
8+
9+
If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs
10+
11+
Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code
12+
13+
Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues.

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
awk -F '\/' '{ print tolower($2) }' |
2323
tr '_' '-'
2424
)
25-
- name: Set up Python 3.6
25+
- name: Set up Python 3.7
2626
uses: actions/setup-python@v1
2727
with:
28-
python-version: 3.6
28+
python-version: 3.7
2929
- name: Versions
3030
run: |
3131
python3 --version
@@ -76,3 +76,5 @@ jobs:
7676
python setup.py sdist
7777
python setup.py bdist_wheel --universal
7878
twine check dist/*
79+
- name: Setup problem matchers
80+
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2021 Scott Shawcroft for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Failure help text
6+
7+
on:
8+
workflow_run:
9+
workflows: ["Build CI"]
10+
types:
11+
- completed
12+
13+
jobs:
14+
post-help:
15+
runs-on: ubuntu-latest
16+
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }}
17+
steps:
18+
- name: Post comment to help
19+
uses: adafruit/circuitpython-action-library-ci-failed@v1

adafruit_progressbar/__init__.py

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,30 @@ def __init__(
7676
value_range: Union[Tuple[int, int], Tuple[float, float]] = (0, 100),
7777
) -> None:
7878

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")
8281

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")
8684

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+
)
9089

9190
_edge_size = 2 * margin_size + 2 * border_thickness
9291

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+
)
9797

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+
)
102103

103104
self._progress = 0.0
104105
self._widget_size = size
@@ -201,9 +202,8 @@ def border_color(self, color: Union[int, Tuple[int, int, int]]) -> None:
201202
:rtype: None
202203
"""
203204

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")
207207

208208
self._border_color = color
209209

@@ -285,13 +285,13 @@ def value(self, value: Union[int, float]) -> None:
285285
:rtype: None
286286
"""
287287

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")
291290

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+
)
295295

296296
# Save off the previous value, so we can pass it in the
297297
# call to "Render"
@@ -332,9 +332,11 @@ def progress(self, value: float) -> None:
332332
:rtype: None
333333
"""
334334

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")
336337

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")
338340

339341
self.value = (self.minimum + (self.maximum - self.minimum)) * (value * 0.01)
340342

@@ -449,19 +451,22 @@ def margin_size(self, value: int) -> None:
449451
:rtype: None
450452
"""
451453

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")
453456

454457
margin_spacing = (2 * value) + (2 * self._border_thickness)
455458

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+
)
465470

466471
self._margin_size = value
467472
self._set_progress(self._progress) # For a render pass

adafruit_progressbar/progressbar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def __init__(
6565

6666
# This needs to remain for backward compatibility, the default ProgressBar class
6767
# should only be able to handle values of type "float"
68-
assert isinstance(progress, float), "Progress must be a floating point value."
68+
if not isinstance(progress, float):
69+
raise TypeError("Progress must be a floating point value.")
6970

7071
super().__init__(
7172
(x, y),

0 commit comments

Comments
 (0)