From 4745233ffd95c608600b99564433411ff76d4c8c Mon Sep 17 00:00:00 2001 From: James Carr Date: Thu, 1 Jul 2021 22:11:15 +0100 Subject: [PATCH 1/3] Improve pre-commit speed on examples pylint --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 354c761..50866b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,7 @@ repos: hooks: - id: pylint_examples name: pylint (examples code) + require_serial: true description: Run pylint rules on "examples/*.py" files entry: /usr/bin/env bash -c args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] From 36c9c76601d7c66dc5d7d6e240808272815cf117 Mon Sep 17 00:00:00 2001 From: James Carr Date: Thu, 1 Jul 2021 22:12:58 +0100 Subject: [PATCH 2/3] Remove max_size parameter --- adafruit_display_text/__init__.py | 2 +- adafruit_display_text/bitmap_label.py | 2 +- adafruit_display_text/label.py | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/adafruit_display_text/__init__.py b/adafruit_display_text/__init__.py index 246f54e..ad10da8 100644 --- a/adafruit_display_text/__init__.py +++ b/adafruit_display_text/__init__.py @@ -217,7 +217,7 @@ def __init__( label_direction: str = "LTR", **kwargs, ) -> None: - super().__init__(max_size=1, x=x, y=y, scale=1, **kwargs) + super().__init__(x=x, y=y, scale=1) self._font = font self._ascent, self._descent = self._get_ascent_descent() diff --git a/adafruit_display_text/bitmap_label.py b/adafruit_display_text/bitmap_label.py index 445c332..f603fab 100755 --- a/adafruit_display_text/bitmap_label.py +++ b/adafruit_display_text/bitmap_label.py @@ -91,7 +91,7 @@ def __init__(self, font, **kwargs) -> None: super().__init__(font, **kwargs) self.local_group = displayio.Group( - max_size=1, scale=kwargs.get("scale", 1) + scale=kwargs.get("scale", 1) ) # local_group holds the tileGrid and sets the scaling self.append( self.local_group diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 497eeda..bb2fd2a 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -81,18 +81,15 @@ def __init__(self, font, **kwargs) -> None: text = kwargs.get("text", "") if not max_glyphs and not text: - raise RuntimeError("Please provide a max size, or initial text") + raise RuntimeError("Please provide a max_glyphs, or initial text") self._tab_replacement = kwargs.get("tab_replacement", (4, " ")) self._tab_text = self._tab_replacement[1] * self._tab_replacement[0] text = self._tab_text.join(text.split("\t")) if not max_glyphs: max_glyphs = len(text) - # add one to max_size for the background bitmap tileGrid # local_group will set the scale - self.local_group = displayio.Group( - max_size=max_glyphs + 1, scale=kwargs.get("scale", 1) - ) + self.local_group = displayio.Group(scale=kwargs.get("scale", 1)) self.append(self.local_group) self.width = max_glyphs From 62497036eb61b55b1383523d688282713a2507fd Mon Sep 17 00:00:00 2001 From: James Carr Date: Thu, 1 Jul 2021 22:14:55 +0100 Subject: [PATCH 3/3] Remove max_size from examples --- examples/display_text_advance_example.py | 2 +- examples/display_text_anchored_position.py | 2 +- examples/display_text_background_color_padding.py | 2 +- examples/display_text_label_vs_bitmap_label_comparison.py | 4 ++-- examples/display_text_pyportal.py | 2 +- examples/display_text_wrap_pixels_test.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/display_text_advance_example.py b/examples/display_text_advance_example.py index 6328fec..393c976 100644 --- a/examples/display_text_advance_example.py +++ b/examples/display_text_advance_example.py @@ -15,7 +15,7 @@ from adafruit_bitmap_font import bitmap_font display = board.DISPLAY -main_group = displayio.Group(max_size=10) +main_group = displayio.Group() MEDIUM_FONT = bitmap_font.load_font("fonts/LeagueSpartan-Bold-16.bdf") BIG_FONT = bitmap_font.load_font("fonts/LibreBodoniv2002-Bold-27.bdf") TIME_PAUSE = 2 diff --git a/examples/display_text_anchored_position.py b/examples/display_text_anchored_position.py index a88c3c2..474993c 100644 --- a/examples/display_text_anchored_position.py +++ b/examples/display_text_anchored_position.py @@ -49,7 +49,7 @@ text_area_bottom_right.anchor_point = (1.0, 1.0) text_area_bottom_right.anchored_position = (DISPLAY_WIDTH, DISPLAY_HEIGHT) -text_group = displayio.Group(max_size=9) +text_group = displayio.Group() text_group.append(text_area_top_middle) text_group.append(text_area_top_left) text_group.append(text_area_top_right) diff --git a/examples/display_text_background_color_padding.py b/examples/display_text_background_color_padding.py index 7968e47..a912b9d 100755 --- a/examples/display_text_background_color_padding.py +++ b/examples/display_text_background_color_padding.py @@ -81,7 +81,7 @@ text.append("MONSTER quops\nnewline quops") # with newline display.auto_refresh = True -myGroup = displayio.Group(max_size=6) +myGroup = displayio.Group() display.show(myGroup) text_area = [] diff --git a/examples/display_text_label_vs_bitmap_label_comparison.py b/examples/display_text_label_vs_bitmap_label_comparison.py index d360952..29f01f4 100644 --- a/examples/display_text_label_vs_bitmap_label_comparison.py +++ b/examples/display_text_label_vs_bitmap_label_comparison.py @@ -161,7 +161,7 @@ print("bitmap_label used: {} memory".format(bitmap_label_start - bitmap_label_end)) -bmap_group = displayio.Group(max_size=4) # Create a group for displaying +bmap_group = displayio.Group() # Create a group for displaying bmap_group.append(bmap_label1) bmap_group.append(bmap_label2) @@ -209,7 +209,7 @@ label_end = gc.mem_free() print("label used: {} memory".format(label_start - label_end)) -label_group = displayio.Group(max_size=4) # Create a group for displaying +label_group = displayio.Group() # Create a group for displaying label_group.append(label1) label_group.append(label2) diff --git a/examples/display_text_pyportal.py b/examples/display_text_pyportal.py index c24dc73..edcfabb 100644 --- a/examples/display_text_pyportal.py +++ b/examples/display_text_pyportal.py @@ -27,7 +27,7 @@ demos = ["CircuitPython = Code + Community", "accents - üàêùéáçãÍóí", "others - αψ◌"] -splash = displayio.Group(max_size=len(fonts) * len(demos)) +splash = displayio.Group() board.DISPLAY.show(splash) max_y = 0 y = 2 diff --git a/examples/display_text_wrap_pixels_test.py b/examples/display_text_wrap_pixels_test.py index 1b0ff60..811abb1 100644 --- a/examples/display_text_wrap_pixels_test.py +++ b/examples/display_text_wrap_pixels_test.py @@ -24,7 +24,7 @@ display = board.DISPLAY # Make the display context -main_group = displayio.Group(max_size=10) +main_group = displayio.Group() display.show(main_group) font = terminalio.FONT