Skip to content

Commit 068599c

Browse files
Remove and update all pylint disables
1 parent 48357d4 commit 068599c

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

adafruit_display_text/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
def wrap_text_to_pixels(
1818
string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
1919
) -> List[str]:
20+
# pylint: disable=too-many-branches, too-many-locals
21+
2022
"""wrap_text_to_pixels function
2123
A helper that will return a list of lines with word-break wrapping.
2224
Leading and trailing whitespace in your string will be removed. If
@@ -34,7 +36,6 @@ def wrap_text_to_pixels(
3436
:rtype: List[str]
3537
3638
"""
37-
# pylint: disable=too-many-locals, too-many-branches
3839
if font is None:
3940

4041
def measure(text):
@@ -153,6 +154,8 @@ def chunks(lst, n):
153154

154155

155156
class LabelBase(Group):
157+
# pylint: disable=too-many-instance-attributes
158+
156159
"""Superclass that all other types of labels will extend. This contains
157160
all of the properties and functions that work the same way in all labels.
158161
@@ -187,7 +190,6 @@ class LabelBase(Group):
187190
:param str label_direction: string defining the label text orientation. See the
188191
subclass documentation for the possible values."""
189192

190-
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals, too-many-arguments
191193
def __init__(
192194
self,
193195
font,
@@ -208,8 +210,10 @@ def __init__(
208210
base_alignment: bool = False,
209211
tab_replacement: Tuple[int, str] = (4, " "),
210212
label_direction: str = "LTR",
211-
**kwargs,
213+
**kwargs, # pylint: disable=unused-argument
212214
) -> None:
215+
# pylint: disable=too-many-arguments, too-many-locals
216+
213217
super().__init__(x=x, y=y, scale=1)
214218

215219
self._font = font

adafruit_display_text/bitmap_label.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ class Label(LabelBase):
8080
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
8181
``UPD``-Upside Down ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``"""
8282

83-
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals, too-many-arguments
84-
# pylint: disable=too-many-branches, no-self-use, too-many-statements
85-
8683
def __init__(self, font, save_text=True, **kwargs) -> None:
8784

8885
super().__init__(font, **kwargs)
@@ -109,6 +106,7 @@ def _reset_text(
109106
line_spacing: float = None,
110107
scale: int = None,
111108
) -> None:
109+
# pylint: disable=too-many-branches, too-many-statements
112110

113111
# Store all the instance variables
114112
if font is not None:
@@ -256,6 +254,8 @@ def _line_spacing_ypixels(font, line_spacing: float) -> int:
256254
def _text_bounding_box(
257255
self, text: str, font
258256
) -> Tuple[int, int, int, int, int, int]:
257+
# pylint: disable=too-many-locals
258+
259259
ascender_max, descender_max = self._ascent, self._descent
260260

261261
lines = 1
@@ -330,7 +330,6 @@ def _text_bounding_box(
330330
final_y_offset_loose,
331331
)
332332

333-
# pylint: disable=too-many-nested-blocks
334333
def _place_text(
335334
self,
336335
bitmap,
@@ -342,6 +341,8 @@ def _place_text(
342341
# when copying glyph bitmaps (this is important for slanted text
343342
# where rectangular glyph boxes overlap)
344343
) -> Tuple[int, int, int, int]:
344+
# pylint: disable=too-many-arguments, too-many-locals
345+
345346
# placeText - Writes text into a bitmap at the specified location.
346347
#
347348
# Note: scale is pushed up to Group level
@@ -441,6 +442,7 @@ def _blit(
441442
skip_index: int = None, # palette index that will not be copied
442443
# (for example: the background color of a glyph)
443444
) -> None:
445+
# pylint: disable=no-self-use, too-many-arguments
444446

445447
if hasattr(bitmap, "blit"): # if bitmap has a built-in blit function, call it
446448
# this function should perform its own input checks

adafruit_display_text/label.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838

3939
class Label(LabelBase):
40+
# pylint: disable=too-many-instance-attributes
41+
4042
"""A label displaying a string of text. The origin point set by ``x`` and ``y``
4143
properties will be the left edge of the bounding box, and in the center of a M
4244
glyph (if its one line), or the (number of lines * linespacing + M)/2. That is,
@@ -77,9 +79,6 @@ class Label(LabelBase):
7779
configurations possibles ``LTR``-Left-To-Right ``RTL``-Right-To-Left
7880
``TTB``-Top-To-Bottom ``UPR``-Upwards ``DWR``-Downwards. It defaults to ``LTR``"""
7981

80-
# pylint: disable=too-many-instance-attributes, too-many-locals
81-
# This has a lot of getters/setters, maybe it needs cleanup.
82-
8382
def __init__(self, font, **kwargs) -> None:
8483
self._background_palette = Palette(1)
8584
self._added_background_tilegrid = False
@@ -226,10 +225,9 @@ def _set_background_color(self, new_color: int) -> None:
226225
self._local_group.pop(0)
227226
self._added_background_tilegrid = False
228227

229-
# pylint: disable = too-many-branches, too-many-statements
230-
def _update_text(
231-
self, new_text: str
232-
) -> None: # pylint: disable=too-many-locals ,too-many-branches, too-many-statements
228+
def _update_text(self, new_text: str) -> None:
229+
# pylint: disable=too-many-branches,too-many-statements
230+
233231
x = 0
234232
y = 0
235233
if self._added_background_tilegrid:
@@ -379,8 +377,10 @@ def _update_text(
379377

380378
while len(self._local_group) > tilegrid_count: # i:
381379
self._local_group.pop()
382-
# pylint: disable=invalid-unary-operand-type
380+
383381
if self._label_direction == "RTL":
382+
# pylint: disable=invalid-unary-operand-type
383+
# type-checkers think left can be None
384384
self._bounding_box = (-left, top, left - right, bottom - top)
385385
if self._label_direction == "TTB":
386386
self._bounding_box = (left, top, right - left, bottom - top)

0 commit comments

Comments
 (0)