From 5a170cb7b15897f9055392f205ffc27e59035b58 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Oct 2023 14:30:31 -0500 Subject: [PATCH 01/16] unpin sphinx and add sphinx-rtd-theme to docs reqs Signed-off-by: foamyguy --- docs/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 797aa04..979f568 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,5 +2,6 @@ # # SPDX-License-Identifier: Unlicense -sphinx>=4.0.0 +sphinx sphinxcontrib-jquery +sphinx-rtd-theme From 057d7fd9facfe60c950d80ae50536c75f0b7b5db Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 7 Oct 2024 09:24:05 -0500 Subject: [PATCH 02/16] remove deprecated get_html_theme_path() call Signed-off-by: foamyguy --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 58baf1e..618ae93 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -127,7 +127,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From eeac41fe029f0a778eed43df9548960ea291bf30 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 15:58:23 -0600 Subject: [PATCH 03/16] list standard colors in the docstrings --- adafruit_turtle.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 23b2a54..3b5c3ae 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -46,21 +46,84 @@ class Color: """Standard colors""" WHITE = 0xFFFFFF + """White 0xFFFFFF + + :meta hide-value:""" + BLACK = 0x000000 + """Black 0x000000 + + :meta hide-value:""" + RED = 0xFF0000 + """Red 0xFF0000 + + :meta hide-value:""" + ORANGE = 0xFFA500 + """Orange 0xFFA500 + + :meta hide-value:""" + YELLOW = 0xFFEE00 + """Yellow 0xFFEE00 + + :meta hide-value:""" + GREEN = 0x00C000 + """Green 0x00C000 + + :meta hide-value:""" + BLUE = 0x0000FF + """Blue 0x0000FF + + :meta hide-value:""" + PURPLE = 0x8040C0 + """Purple 0x8040C0 + + :meta hide-value:""" + PINK = 0xFF40C0 + """Pink 0xFF40C0 + + :meta hide-value:""" + LIGHT_GRAY = 0xAAAAAA + """Light Gray 0xAAAAAA + + :meta hide-value:""" + GRAY = 0x444444 + """Gray 0x444444 + + :meta hide-value:""" + BROWN = 0xCA801D + """Brown 0xCA801D + + :meta hide-value:""" + DARK_GREEN = 0x008700 + """Dark Green 0x008700 + + :meta hide-value:""" + TURQUOISE = 0x00C0C0 + """Turquoise 0x00C0C0 + + :meta hide-value:""" + DARK_BLUE = 0x0000AA + """Dark Blue 0x0000AA + + :meta hide-value:""" + DARK_RED = 0x800000 + """Dark Red 0x800000 + + :meta hide-value:""" colors = ( BLACK, From ebd591df4541211b42ee31a8531494d7ed967c45 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 16:02:41 -0600 Subject: [PATCH 04/16] remove duplicate color name --- adafruit_turtle.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 3b5c3ae..c7c41ea 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -46,83 +46,83 @@ class Color: """Standard colors""" WHITE = 0xFFFFFF - """White 0xFFFFFF + """0xFFFFFF :meta hide-value:""" BLACK = 0x000000 - """Black 0x000000 + """0x000000 :meta hide-value:""" RED = 0xFF0000 - """Red 0xFF0000 + """0xFF0000 :meta hide-value:""" ORANGE = 0xFFA500 - """Orange 0xFFA500 + """0xFFA500 :meta hide-value:""" YELLOW = 0xFFEE00 - """Yellow 0xFFEE00 + """0xFFEE00 :meta hide-value:""" GREEN = 0x00C000 - """Green 0x00C000 + """0x00C000 :meta hide-value:""" BLUE = 0x0000FF - """Blue 0x0000FF + """0x0000FF :meta hide-value:""" PURPLE = 0x8040C0 - """Purple 0x8040C0 + """0x8040C0 :meta hide-value:""" PINK = 0xFF40C0 - """Pink 0xFF40C0 + """0xFF40C0 :meta hide-value:""" LIGHT_GRAY = 0xAAAAAA - """Light Gray 0xAAAAAA + """0xAAAAAA :meta hide-value:""" GRAY = 0x444444 - """Gray 0x444444 + """0x444444 :meta hide-value:""" BROWN = 0xCA801D - """Brown 0xCA801D + """0xCA801D :meta hide-value:""" DARK_GREEN = 0x008700 - """Dark Green 0x008700 + """0x008700 :meta hide-value:""" TURQUOISE = 0x00C0C0 - """Turquoise 0x00C0C0 + """0x00C0C0 :meta hide-value:""" DARK_BLUE = 0x0000AA - """Dark Blue 0x0000AA + """0x0000AA :meta hide-value:""" DARK_RED = 0x800000 - """Dark Red 0x800000 - + """0x800000 + :meta hide-value:""" colors = ( From 0c57fd42dcf745ffa75a9e318a252b9ad001087b Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 16:06:44 -0600 Subject: [PATCH 05/16] format --- adafruit_turtle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index c7c41ea..b501c22 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -122,7 +122,7 @@ class Color: DARK_RED = 0x800000 """0x800000 - + :meta hide-value:""" colors = ( From f2ae512e0e86c6e70dcd2c04251480c98526ebb2 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 Dec 2024 17:24:48 -0600 Subject: [PATCH 06/16] default to "standard" mode --- adafruit_turtle.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 23b2a54..b255b84 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -171,11 +171,11 @@ def __init__( self._y = self._h // (2 * scale) self._speed = 6 self._heading: float = 0 - self._logomode = True self._fullcircle = 360.0 self._degreesPerAU = 1.0 - self._angleOrient = 1 - self._angleOffset: float = 0 + self._logomode = False + self._angleOrient = -1 + self._angleOffset: float = self._fullcircle / 4 self._bg_color = 0 self._splash: displayio.Group = displayio.Group() From e921f796f1578e6b87cd369f0735a9e07b071a0d Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Dec 2024 09:30:24 -0600 Subject: [PATCH 07/16] make circle and dot always use degrees internally --- adafruit_turtle.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index c9d7f97..ed5a550 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -626,6 +626,12 @@ def circle( # --or: circle(radius, extent) # arc # --or: circle(radius, extent, steps) # --or: circle(radius, steps=6) # 6-sided polygon + change_back = False + if not self._in_degrees(): + change_back = True + original_mode = "standard" if not self._logomode else "logo" + self.degrees() + self.mode("standard") pos = self.pos() h = self._heading if extent is None: @@ -647,6 +653,9 @@ def circle( # get back to exact same position and heading self.goto(pos) self.setheading(h) + if change_back: + self.radians() + self.mode(original_mode) # pylint: disable=possibly-used-before-assignment # pylint:disable=inconsistent-return-statements def speed(self, speed: Optional[int] = None) -> Optional[int]: @@ -690,6 +699,13 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: :param color: the color of the dot """ + change_back = False + if not self._in_degrees(): + change_back = True + original_mode = "standard" if not self._logomode else "logo" + print(f"old mode: {original_mode}") + self.degrees() + self.mode("standard") if size is None: size = max(self._pensize + 4, self._pensize * 2) if color is None: @@ -713,6 +729,9 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: self._pensize = 1 self._plot(self._x, self._y, color) self._pensize = pensize + if change_back: + self.radians() + self.mode(original_mode) # pylint: disable=possibly-used-before-assignment def stamp( self, @@ -882,6 +901,10 @@ def degrees(self, fullcircle: float = 360) -> None: """ self._setDegreesPerAU(fullcircle) + def _in_degrees(self) -> bool: + print(self._degreesPerAU) + return self._degreesPerAU == 1.0 + def radians(self) -> None: """Set the angle measurement units to radians. Equivalent to degrees(2*math.pi).""" From 96222c342964255c0a4f23d2cf7f077a408dec3f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Dec 2024 10:12:15 -0600 Subject: [PATCH 08/16] remove space --- adafruit_turtle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index ed5a550..dfa6d0e 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -655,7 +655,7 @@ def circle( self.setheading(h) if change_back: self.radians() - self.mode(original_mode) # pylint: disable=possibly-used-before-assignment + self.mode(original_mode) # pylint:disable=possibly-used-before-assignment # pylint:disable=inconsistent-return-statements def speed(self, speed: Optional[int] = None) -> Optional[int]: @@ -731,7 +731,7 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: self._pensize = pensize if change_back: self.radians() - self.mode(original_mode) # pylint: disable=possibly-used-before-assignment + self.mode(original_mode) # pylint:disable=possibly-used-before-assignment def stamp( self, From 591b805474ebc34297c45f7416c2ad389588cc73 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Dec 2024 10:16:11 -0600 Subject: [PATCH 09/16] remove pylint disables --- adafruit_turtle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index dfa6d0e..df57e77 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -655,7 +655,7 @@ def circle( self.setheading(h) if change_back: self.radians() - self.mode(original_mode) # pylint:disable=possibly-used-before-assignment + self.mode(original_mode) # pylint:disable=inconsistent-return-statements def speed(self, speed: Optional[int] = None) -> Optional[int]: @@ -731,7 +731,7 @@ def dot(self, size: Optional[int] = None, color: Optional[int] = None) -> None: self._pensize = pensize if change_back: self.radians() - self.mode(original_mode) # pylint:disable=possibly-used-before-assignment + self.mode(original_mode) def stamp( self, From 614e9e2b4fd2012679b8a35f49126495c12c3fb9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 4 Dec 2024 17:51:34 -0600 Subject: [PATCH 10/16] Account for fractions of a pixel when drawing Previously, the endpoint of the line was always moved along in increments of 1 pixel, so that the endpoint would always be rounded down. This could accumulate to give quite large differences from what the program intended. Ensure that "goto" always ends up storing the floating point endpoints and that the line is drawn from the rounded-integer starting coordinate and rounded-integer ending coordinate. This makes the 3 test lines in the OP's "turtle_truncate.txt" example be the same length. Closes: #41 --- adafruit_turtle.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index c9d7f97..54cdcf4 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -407,13 +407,17 @@ def goto( xn: float = x1[0] if y1 is None else x1 # type: ignore xn += self._w // 2 yn = self._h // 2 - yn - x0 = self._x - y0 = self._y if not self.isdown(): self._x = xn # woot, we just skip ahead self._y = yn self._drawturtle() return + + self._do_draw_line(round(self._x), round(self._y), round(xn), round(yn)) + self._x = xn + self._y = yn + + def _do_draw_line(self, x0: int, y0: int, xn: int, yn: int): steep = abs(yn - y0) > abs(xn - x0) rev = False dx = xn - x0 @@ -444,15 +448,11 @@ def goto( self._plot(int(y0), int(x0), self._pencolor) except IndexError: pass - self._x = y0 - self._y = x0 else: try: self._plot(int(x0), int(y0), self._pencolor) except IndexError: pass - self._x = x0 - self._y = y0 if self._speed > 0: if step >= self._speed: # mark the step From 277983a83636bd1bba1f50b40bea7dd27692be85 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 9 Dec 2024 09:12:37 -0600 Subject: [PATCH 11/16] fix for visible turtle location --- adafruit_turtle.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 54cdcf4..5c40b4d 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -311,6 +311,8 @@ def __init__( self._turtle_pic = None self._turtle_odb = None self._turtle_alt_sprite = None + self._turtle_x = self._x + self._turtle_y = self._y self._drawturtle() self._stamps = {} self._turtle_odb_use = 0 @@ -323,15 +325,23 @@ def __init__( def _drawturtle(self) -> None: if self._turtle_pic is None: - self._turtle_sprite.x = int(self._x - 4) - self._turtle_sprite.y = int(self._y - 4) + self._turtle_sprite.x = int(self._turtle_x - 4) + self._turtle_sprite.y = int(self._turtle_y - 4) else: if self._turtle_odb is not None: - self._turtle_alt_sprite.x = int(self._x - self._turtle_odb.width // 2) - self._turtle_alt_sprite.y = int(self._y - self._turtle_odb.height // 2) + self._turtle_alt_sprite.x = int( + self._turtle_x - self._turtle_odb.width // 2 + ) + self._turtle_alt_sprite.y = int( + self._turtle_y - self._turtle_odb.height // 2 + ) else: - self._turtle_alt_sprite.x = int(self._x - self._turtle_pic[0] // 2) - self._turtle_alt_sprite.y = int(self._y - self._turtle_pic[1] // 2) + self._turtle_alt_sprite.x = int( + self._turtle_x - self._turtle_pic[0] // 2 + ) + self._turtle_alt_sprite.y = int( + self._turtle_y - self._turtle_pic[1] // 2 + ) ########################################################################### # Move and draw @@ -448,11 +458,15 @@ def _do_draw_line(self, x0: int, y0: int, xn: int, yn: int): self._plot(int(y0), int(x0), self._pencolor) except IndexError: pass + self._turtle_x = y0 + self._turtle_y = x0 else: try: self._plot(int(x0), int(y0), self._pencolor) except IndexError: pass + self._turtle_x = x0 + self._turtle_y = y0 if self._speed > 0: if step >= self._speed: # mark the step From 5aaa6abd758af2e0b0d46744634617285d992700 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 12/16] add sphinx configuration to rtd.yaml Signed-off-by: foamyguy --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 33c2a61..88bca9f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,6 +8,9 @@ # Required version: 2 +sphinx: + configuration: docs/conf.py + build: os: ubuntu-20.04 tools: From cb4511ae61697247bb473741fb52b6b9e12a67cf Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Thu, 27 Feb 2025 15:43:54 -0800 Subject: [PATCH 13/16] Remove secrets usage --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 618ae93..e4137e6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,7 +39,6 @@ "adafruit_bitmap_font", "adafruit_display_text", "adafruit_esp32spi", - "secrets", "adafruit_sdcard", "storage", "adafruit_io", From 8ee4425a0d3bb330cac773c4f52840dcb8308a92 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 16 May 2025 19:34:43 +0000 Subject: [PATCH 14/16] change to ruff --- .gitattributes | 11 + .pre-commit-config.yaml | 43 +-- .pylintrc | 399 -------------------------- README.rst | 6 +- adafruit_turtle.py | 52 +--- docs/api.rst | 3 + docs/conf.py | 8 +- examples/turtle_benzene.py | 1 + examples/turtle_bgpic_changeturtle.py | 1 + examples/turtle_circle.py | 1 + examples/turtle_circle_hex.py | 1 + examples/turtle_dots.py | 1 + examples/turtle_hilbert.py | 3 +- examples/turtle_koch.py | 3 +- examples/turtle_manual_hex.py | 1 + examples/turtle_overlayed_koch.py | 5 +- examples/turtle_sierpinski.py | 1 + examples/turtle_simpletest.py | 1 + examples/turtle_square.py | 1 + examples/turtle_star.py | 1 + examples/turtle_swirl.py | 3 +- ruff.toml | 111 +++++++ 22 files changed, 172 insertions(+), 485 deletions(-) create mode 100644 .gitattributes delete mode 100644 .pylintrc create mode 100644 ruff.toml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..21c125c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + +.py text eol=lf +.rst text eol=lf +.txt text eol=lf +.yaml text eol=lf +.toml text eol=lf +.license text eol=lf +.md text eol=lf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70ade69..ff19dde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,42 +1,21 @@ -# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries # # SPDX-License-Identifier: Unlicense repos: - - repo: https://github.com/python/black - rev: 23.3.0 - hooks: - - id: black - - repo: https://github.com/fsfe/reuse-tool - rev: v1.1.2 - hooks: - - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/pycqa/pylint - rev: v2.17.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.4 hooks: - - id: pylint - name: pylint (library code) - types: [python] - args: - - --disable=consider-using-f-string - exclude: "^(docs/|examples/|tests/|setup.py$)" - - id: pylint - name: pylint (example code) - description: Run pylint rules on "examples/*.py" files - types: [python] - files: "^examples/" - args: - - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code - - id: pylint - name: pylint (test code) - description: Run pylint rules on "tests/*.py" files - types: [python] - files: "^tests/" - args: - - --disable=missing-docstring,consider-using-f-string,duplicate-code + - id: ruff-format + - id: ruff + args: ["--fix"] + - repo: https://github.com/fsfe/reuse-tool + rev: v3.0.1 + hooks: + - id: reuse diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index f945e92..0000000 --- a/.pylintrc +++ /dev/null @@ -1,399 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# -# SPDX-License-Identifier: Unlicense - -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Add files or directories to the ignore-list. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the ignore-list. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins=pylint.extensions.no_self_use - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call -disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -# notes=FIXME,XXX,TODO -notes=FIXME,XXX - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=board - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -# expected-line-ending-format= -expected-line-ending-format=LF - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=1000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=yes - -# Minimum lines number of a similarity. -min-similarity-lines=12 - - -[BASIC] - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class names -# class-rgx=[A-Z_][a-zA-Z0-9]+$ -class-rgx=[A-Z_][a-zA-Z0-9_]+$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -# good-names=i,j,k,ex,Run,_ -good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -# max-attributes=7 -max-attributes=11 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=1 - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=builtins.Exception diff --git a/README.rst b/README.rst index 3ff3f72..b61954f 100644 --- a/README.rst +++ b/README.rst @@ -13,9 +13,9 @@ Introduction :target: https://github.com/adafruit/Adafruit_CircuitPython_turtle/actions/ :alt: Build Status -.. image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/psf/black - :alt: Code Style: Black +.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json + :target: https://github.com/astral-sh/ruff + :alt: Code Style: Ruff Turtle graphics library for CircuitPython and displayio diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 1df457a..2288978 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -23,14 +23,15 @@ * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice """ + from __future__ import annotations # pylint:disable=too-many-public-methods, too-many-instance-attributes, invalid-name # pylint:disable=too-few-public-methods, too-many-lines, too-many-arguments - import gc import math import time + import displayio try: @@ -205,28 +206,22 @@ def __getnewargs__(self) -> Tuple[float, float]: return (self[0], self[1]) def __repr__(self) -> str: - return "({:.2f},{:.2f})".format(self[0], self[1]) + return f"({self[0]:.2f},{self[1]:.2f})" class turtle: """A Turtle that can be given commands to draw.""" - # pylint:disable=too-many-statements - def __init__( - self, display: Optional[displayio.Display] = None, scale: float = 1 - ) -> None: + def __init__(self, display: Optional[displayio.Display] = None, scale: float = 1) -> None: if display: self._display = display else: try: - # pylint: disable=import-outside-toplevel import board self._display = board.DISPLAY except AttributeError as err: - raise RuntimeError( - "No display available. One must be provided." - ) from err + raise RuntimeError("No display available. One must be provided.") from err self._w: int = self._display.width self._h: int = self._display.height @@ -327,21 +322,12 @@ def _drawturtle(self) -> None: if self._turtle_pic is None: self._turtle_sprite.x = int(self._turtle_x - 4) self._turtle_sprite.y = int(self._turtle_y - 4) + elif self._turtle_odb is not None: + self._turtle_alt_sprite.x = int(self._turtle_x - self._turtle_odb.width // 2) + self._turtle_alt_sprite.y = int(self._turtle_y - self._turtle_odb.height // 2) else: - if self._turtle_odb is not None: - self._turtle_alt_sprite.x = int( - self._turtle_x - self._turtle_odb.width // 2 - ) - self._turtle_alt_sprite.y = int( - self._turtle_y - self._turtle_odb.height // 2 - ) - else: - self._turtle_alt_sprite.x = int( - self._turtle_x - self._turtle_pic[0] // 2 - ) - self._turtle_alt_sprite.y = int( - self._turtle_y - self._turtle_pic[1] // 2 - ) + self._turtle_alt_sprite.x = int(self._turtle_x - self._turtle_pic[0] // 2) + self._turtle_alt_sprite.y = int(self._turtle_y - self._turtle_pic[1] // 2) ########################################################################### # Move and draw @@ -352,9 +338,7 @@ def forward(self, distance: float) -> None: :param distance: how far to move (integer or float) """ p = self.pos() - angle = ( - self._angleOffset + self._angleOrient * self._heading - ) % self._fullcircle + angle = (self._angleOffset + self._angleOrient * self._heading) % self._fullcircle x1 = p[0] + math.sin(math.radians(angle)) * distance y1 = p[1] + math.cos(math.radians(angle)) * distance self.goto(x1, y1) @@ -545,9 +529,7 @@ def _plot(self, x: float, y: float, c: int) -> None: except IndexError: pass r = self._pensize // 2 + 1 - angle = ( - self._angleOffset + self._angleOrient * self._heading - 90 - ) % self._fullcircle + angle = (self._angleOffset + self._angleOrient * self._heading - 90) % self._fullcircle sin = math.sin(math.radians(angle)) cos = math.cos(math.radians(angle)) x0 = x + sin * r @@ -826,7 +808,7 @@ def clearstamps(self, n: Optional[int] = None) -> None: """ i = 1 - for sid in self._stamps: # pylint: disable=consider-using-dict-items + for sid in self._stamps: if self._stamps[sid] is not None: self.clearstamp(sid) if n is not None and i >= n: @@ -1230,9 +1212,7 @@ def changeturtle( self._turtle_group.append(self._turtle_alt_sprite) self._drawturtle() else: - raise TypeError( - 'Argument must be "str", a "displayio.TileGrid" or nothing.' - ) + raise TypeError('Argument must be "str", a "displayio.TileGrid" or nothing.') # pylint:enable=too-many-statements, too-many-branches @@ -1247,9 +1227,7 @@ def _turn(self, angle: float) -> None: self._heading %= self._fullcircle # wrap return start_angle = self._heading - steps = math.ceil( - (self._pensize * 2) * 3.1415 * (abs(angle) / self._fullcircle) - ) + steps = math.ceil((self._pensize * 2) * 3.1415 * (abs(angle) / self._fullcircle)) if steps < 1: d_angle = angle steps = 1 diff --git a/docs/api.rst b/docs/api.rst index db048c0..31d0e34 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4,5 +4,8 @@ .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) .. use this format as the module name: "adafruit_foo.foo" +API Reference +############# + .. automodule:: adafruit_turtle :members: diff --git a/docs/conf.py b/docs/conf.py index e4137e6..f4402aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- - # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # # SPDX-License-Identifier: MIT +import datetime import os import sys -import datetime sys.path.insert(0, os.path.abspath("..")) @@ -70,9 +68,7 @@ creation_year = "2019" current_year = str(datetime.datetime.now().year) year_duration = ( - current_year - if current_year == creation_year - else creation_year + " - " + current_year + current_year if current_year == creation_year else creation_year + " - " + current_year ) copyright = year_duration + " Adafruit" author = "Adafruit" diff --git a/examples/turtle_benzene.py b/examples/turtle_benzene.py index 5c1eb91..d9c470e 100644 --- a/examples/turtle_benzene.py +++ b/examples/turtle_benzene.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_bgpic_changeturtle.py b/examples/turtle_bgpic_changeturtle.py index e461854..e2b0d91 100644 --- a/examples/turtle_bgpic_changeturtle.py +++ b/examples/turtle_bgpic_changeturtle.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_circle.py b/examples/turtle_circle.py index 51c111e..d4ca9aa 100644 --- a/examples/turtle_circle.py +++ b/examples/turtle_circle.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_circle_hex.py b/examples/turtle_circle_hex.py index 5f02a4a..af4f0b5 100644 --- a/examples/turtle_circle_hex.py +++ b/examples/turtle_circle_hex.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_dots.py b/examples/turtle_dots.py index 3baa449..9297ad8 100644 --- a/examples/turtle_dots.py +++ b/examples/turtle_dots.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import turtle print("Turtle time! Lets draw a square with dots") diff --git a/examples/turtle_hilbert.py b/examples/turtle_hilbert.py index 6413d3a..8427712 100644 --- a/examples/turtle_hilbert.py +++ b/examples/turtle_hilbert.py @@ -1,9 +1,8 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -# pylint: disable=unnecessary-lambda-assignment - import board + from adafruit_turtle import turtle diff --git a/examples/turtle_koch.py b/examples/turtle_koch.py index f04c919..1e5b681 100644 --- a/examples/turtle_koch.py +++ b/examples/turtle_koch.py @@ -1,9 +1,8 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -# pylint: disable=unnecessary-lambda-assignment - import board + from adafruit_turtle import turtle diff --git a/examples/turtle_manual_hex.py b/examples/turtle_manual_hex.py index 11e54a4..d407a6c 100644 --- a/examples/turtle_manual_hex.py +++ b/examples/turtle_manual_hex.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_overlayed_koch.py b/examples/turtle_overlayed_koch.py index 0bfe018..662ae92 100644 --- a/examples/turtle_overlayed_koch.py +++ b/examples/turtle_overlayed_koch.py @@ -1,10 +1,9 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT -# pylint: disable=unnecessary-lambda-assignment - import board -from adafruit_turtle import turtle, Color + +from adafruit_turtle import Color, turtle generation_colors = [Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW] diff --git a/examples/turtle_sierpinski.py b/examples/turtle_sierpinski.py index 5c63ea5..c01f039 100644 --- a/examples/turtle_sierpinski.py +++ b/examples/turtle_sierpinski.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import turtle diff --git a/examples/turtle_simpletest.py b/examples/turtle_simpletest.py index 7a0c68e..6f1681a 100644 --- a/examples/turtle_simpletest.py +++ b/examples/turtle_simpletest.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_square.py b/examples/turtle_square.py index 6d9486f..0a3aaaf 100644 --- a/examples/turtle_square.py +++ b/examples/turtle_square.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_star.py b/examples/turtle_star.py index 7a0c68e..6f1681a 100644 --- a/examples/turtle_star.py +++ b/examples/turtle_star.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT import board + from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/examples/turtle_swirl.py b/examples/turtle_swirl.py index fab441e..62ca218 100644 --- a/examples/turtle_swirl.py +++ b/examples/turtle_swirl.py @@ -2,7 +2,8 @@ # SPDX-License-Identifier: MIT import board -from adafruit_turtle import turtle, Color + +from adafruit_turtle import Color, turtle turtle = turtle(board.DISPLAY) diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..f732478 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,111 @@ +# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +target-version = "py38" +line-length = 100 + +[lint] +preview = true +select = ["I", "PL", "UP"] + +extend-select = [ + "D419", # empty-docstring + "E501", # line-too-long + "W291", # trailing-whitespace + "PLC0414", # useless-import-alias + "PLC2401", # non-ascii-name + "PLC2801", # unnecessary-dunder-call + "PLC3002", # unnecessary-direct-lambda-call + "E999", # syntax-error + "PLE0101", # return-in-init + "F706", # return-outside-function + "F704", # yield-outside-function + "PLE0116", # continue-in-finally + "PLE0117", # nonlocal-without-binding + "PLE0241", # duplicate-bases + "PLE0302", # unexpected-special-method-signature + "PLE0604", # invalid-all-object + "PLE0605", # invalid-all-format + "PLE0643", # potential-index-error + "PLE0704", # misplaced-bare-raise + "PLE1141", # dict-iter-missing-items + "PLE1142", # await-outside-async + "PLE1205", # logging-too-many-args + "PLE1206", # logging-too-few-args + "PLE1307", # bad-string-format-type + "PLE1310", # bad-str-strip-call + "PLE1507", # invalid-envvar-value + "PLE2502", # bidirectional-unicode + "PLE2510", # invalid-character-backspace + "PLE2512", # invalid-character-sub + "PLE2513", # invalid-character-esc + "PLE2514", # invalid-character-nul + "PLE2515", # invalid-character-zero-width-space + "PLR0124", # comparison-with-itself + "PLR0202", # no-classmethod-decorator + "PLR0203", # no-staticmethod-decorator + "UP004", # useless-object-inheritance + "PLR0206", # property-with-parameters + "PLR0904", # too-many-public-methods + "PLR0911", # too-many-return-statements + "PLR0912", # too-many-branches + "PLR0913", # too-many-arguments + "PLR0914", # too-many-locals + "PLR0915", # too-many-statements + "PLR0916", # too-many-boolean-expressions + "PLR1702", # too-many-nested-blocks + "PLR1704", # redefined-argument-from-local + "PLR1711", # useless-return + "C416", # unnecessary-comprehension + "PLR1733", # unnecessary-dict-index-lookup + "PLR1736", # unnecessary-list-index-lookup + + # ruff reports this rule is unstable + #"PLR6301", # no-self-use + + "PLW0108", # unnecessary-lambda + "PLW0120", # useless-else-on-loop + "PLW0127", # self-assigning-variable + "PLW0129", # assert-on-string-literal + "B033", # duplicate-value + "PLW0131", # named-expr-without-context + "PLW0245", # super-without-brackets + "PLW0406", # import-self + "PLW0602", # global-variable-not-assigned + "PLW0603", # global-statement + "PLW0604", # global-at-module-level + + # fails on the try: import typing used by libraries + #"F401", # unused-import + + "F841", # unused-variable + "E722", # bare-except + "PLW0711", # binary-op-exception + "PLW1501", # bad-open-mode + "PLW1508", # invalid-envvar-default + "PLW1509", # subprocess-popen-preexec-fn + "PLW2101", # useless-with-lock + "PLW3301", # nested-min-max +] + +ignore = [ + "PLR2004", # magic-value-comparison + "UP030", # format literals + "PLW1514", # unspecified-encoding + "PLR0913", # too-many-arguments + "PLR0915", # too-many-statements + "PLR0917", # too-many-positional-arguments + "PLR0904", # too-many-public-methods + "PLR0912", # too-many-branches + "PLR0916", # too-many-boolean-expressions + "PLR6301", # could-be-static no-self-use + "PLC0415", # import outside toplevel + "PLC2701", # private import + "UP007", # x | y typing + "UP006", # builtin instead of typing import + "PLR0914", # too many locals +] + +[format] +line-ending = "lf" From 3446470fa1687dedea1c0f68cd4659396937c22e Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 27 May 2025 16:28:36 -0500 Subject: [PATCH 15/16] displayio API update --- adafruit_turtle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_turtle.py b/adafruit_turtle.py index 2288978..4022ed9 100644 --- a/adafruit_turtle.py +++ b/adafruit_turtle.py @@ -36,6 +36,8 @@ try: from typing import List, Optional, Tuple, Union + + import busdisplay except ImportError: pass @@ -212,7 +214,7 @@ def __repr__(self) -> str: class turtle: """A Turtle that can be given commands to draw.""" - def __init__(self, display: Optional[displayio.Display] = None, scale: float = 1) -> None: + def __init__(self, display: Optional[busdisplay.BusDisplay] = None, scale: float = 1) -> None: if display: self._display = display else: From 3b7cc0a51fad5ab49ed791a8441a7c671a204fb8 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 4 Jun 2025 10:00:20 -0500 Subject: [PATCH 16/16] update rtd.yml file Signed-off-by: foamyguy --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 88bca9f..255dafd 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,7 +12,7 @@ sphinx: configuration: docs/conf.py build: - os: ubuntu-20.04 + os: ubuntu-lts-latest tools: python: "3"