Skip to content

Commit a0836c9

Browse files
committed
Fixup some Pylint issues
1 parent a9ee271 commit a0836c9

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

adafruit_progressbar/__init__.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ProgressBarBase(displayio.TileGrid):
3232
:type position: Tuple[int, int]
3333
:param size: The size (width, height) of the progress bar
3434
:type size: Tuple[int, int]
35-
:param start_value: The beginning value of the progress bar. This value
35+
:param start_value: The beginning value of the progress bar. This value
3636
is displayed when the progress bar is first visible,
3737
if it hasn't been updated.
3838
:type start_value: float
@@ -139,6 +139,7 @@ def progress(self):
139139

140140
@property
141141
def border_thickness(self):
142+
"""Gets the currently configured thickness of the border (in pixels)"""
142143
return self._border_thickness
143144

144145
@progress.setter
@@ -149,10 +150,10 @@ def progress(self, value):
149150
bar. Must be between 0.0-1.0
150151
"""
151152
_old_value = self._progress
152-
# If we're using floats, from 0.0 to 1.0, using 4 decimal places allows us to handle values as
153-
# precise as 0.23456, which evaluates to a percentage value of 23.45% (with rounding)
153+
# If we're using floats, from 0.0 to 1.0, using 4 decimal places allows us to handle values
154+
# as precise as 0.23456, which evaluates to a percentage value of 23.45% (with rounding)
154155
self._progress = round(value, 4)
155-
self.render(_old_value, self.progress)
156+
self.render(_old_value, self.progress, self.progress)
156157

157158
@property
158159
def range(self):
@@ -184,16 +185,21 @@ def _draw_outline(self):
184185
self._bitmap[line, _h] = 1
185186
self._bitmap[self.width - 1 - line, _h] = 1
186187

187-
def render(self, _old_value, _new_value):
188+
def render(self, _old_value, _new_value, _progress_value) -> None:
188189
"""The method called when the display needs to be updated. This method
189190
can be overridden in child classes to handle the graphics appropriately.
190191
191-
:param _old_value: float: The value from which we're updating
192-
:param _new_value: float: The value to which we're updating
193-
192+
:param _old_value: The value from which we're updating
193+
:type _old_value: float
194+
:param _new_value: The value to which we're updating
195+
:type _new_value: float
196+
:param _progress_value: The value of the progress, or ratio between the new value and the
197+
maximum value
198+
:type _progress_value: float
199+
:rtype None:
194200
"""
195201

196-
def info():
202+
def info(self):
197203
"""This is the `info` method. It gives you info.
198204
199205
This information is usefull for debugging, and

adafruit_progressbar/progressbar.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,18 @@ def __init__(
7070
(width, height),
7171
progress,
7272
bar_color,
73-
0xAAAAAA,
73+
outline_color,
7474
0x444444,
7575
border_thickness=stroke,
7676
show_margin=True,
7777
value_range=(0.0, 1.0),
7878
)
7979

80+
_outline_color: int # The colour used for the border of the widget
81+
8082
@property
8183
def progress(self):
84+
"""Returns the current progress value (percentage)"""
8285
return ProgressBarBase.progress.fget(self)
8386

8487
@progress.setter
@@ -93,8 +96,15 @@ def progress(self, value):
9396
value, float
9497
), "Progress value must be a floating point value."
9598

99+
# pylint: disable=no-member
96100
ProgressBarBase.progress.fset(self, value)
97101

102+
@property
103+
def outline_color(self):
104+
"""Returns the currently configured value for the color of the
105+
outline (border) of the widget."""
106+
return self._outline_color
107+
98108
@property
99109
def fill(self):
100110
"""The fill of the progress bar. Can be a hex value for a color or ``None`` for
@@ -114,7 +124,7 @@ def fill(self, color):
114124
self._palette[2] = color
115125
self._palette.make_opaque(0)
116126

117-
def render(self, _previous_value, _new_value, _progress_value):
127+
def render(self, _previous_value, _new_value, _progress_value) -> None:
118128
"""
119129
The rendering mechanism to display the newly set value.
120130
@@ -125,7 +135,7 @@ def render(self, _previous_value, _new_value, _progress_value):
125135
:param _progress_value: The value of the progress, or ratio between the new value and the
126136
maximum value
127137
:type _progress_value: float
128-
:return: None
138+
:rtype None:
129139
"""
130140
# print("Calling 'super().render()' before our own code")
131141
# super().render()

adafruit_progressbar/verticalprogressbar.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
"""
2525

2626
# imports
27-
from . import ProgressBarBase
2827
import displayio
28+
from . import ProgressBarBase
29+
2930

31+
# pylint: disable=too-few-public-methods
32+
class FillDirection(enumerate):
33+
"""Enums to define the direction in which the progressbar
34+
should fill"""
3035

31-
class FillDirection(object):
3236
LEFT_TO_RIGHT = 0
3337
DEFAULT = LEFT_TO_RIGHT
3438
BOTTOM_UP = 1
@@ -209,7 +213,7 @@ def progress(self, value):
209213

210214
# DEBUG
211215
print(
212-
f"Start: {_start} End: {_end} Incr: {_incr} Size: {_new_value_size} Color: {_color}"
216+
f"Start: {_start} End: {_end} Incr: {_incr} Size: {_new_value_size} Color: {_color}"
213217
)
214218

215219
# Because range() is ( from-include, to-exclude )...

0 commit comments

Comments
 (0)