From 6015a6ab60af3bf1ac721267df0f7f6a6d3646d1 Mon Sep 17 00:00:00 2001 From: Paul Cutler Date: Fri, 3 Nov 2023 10:30:22 -0500 Subject: [PATCH 01/12] Update to use root_group for CP 9 compatibility --- examples/clue_ams_remote_advanced.py | 2 +- examples/clue_ble_color_patchwork.py | 2 +- examples/clue_spirit_level.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/clue_ams_remote_advanced.py b/examples/clue_ams_remote_advanced.py index 1f2b002..1b21ac8 100644 --- a/examples/clue_ams_remote_advanced.py +++ b/examples/clue_ams_remote_advanced.py @@ -84,7 +84,7 @@ volume_inner = Rect(15, 170, 1, 20, fill=0xFFFFFF, outline=0xFFFFFF) group.append(volume_inner) -display.show(group) +display.root_group = group time.sleep(0.01) width1 = 1 diff --git a/examples/clue_ble_color_patchwork.py b/examples/clue_ble_color_patchwork.py index bd73e0f..4b8a561 100644 --- a/examples/clue_ble_color_patchwork.py +++ b/examples/clue_ble_color_patchwork.py @@ -207,7 +207,7 @@ def change_advertisement(color): group.append(patchwork_group) # Add the Group to the Display -display.show(group) +display.root_group = group cur_color = 0 diff --git a/examples/clue_spirit_level.py b/examples/clue_spirit_level.py index ed36a70..02d075e 100755 --- a/examples/clue_spirit_level.py +++ b/examples/clue_spirit_level.py @@ -23,7 +23,7 @@ bubble_group.append(level_bubble) clue_group.append(bubble_group) -display.show(clue_group) +display.root_group = clue_group while True: x, y, _ = clue.acceleration From e0bfd1e46b57fae11d9d4fbabeb0fcca2c18ec41 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Oct 2023 14:30:31 -0500 Subject: [PATCH 02/12] 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 ef36b5600d95fb0ebfab0c892187328174a7d3b8 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 8 Jan 2024 14:57:31 -0600 Subject: [PATCH 03/12] update simpletext display inner class for root_group displayio API 9.x --- adafruit_clue.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_clue.py b/adafruit_clue.py index 1628233..85d4bbf 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -59,6 +59,7 @@ import audiopwmio import audiocore import touchio +from displayio import CIRCUITPYTHON_TERMINAL __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CLUE.git" @@ -150,11 +151,11 @@ def add_text_line(self, color: Union[int, Tuple[int, int, int]] = 0xFFFFFF): def show(self): """Call show() to display the data list.""" - self._display.show(self.text_group) + self._display.root_group = self.text_group def show_terminal(self): """Revert to terminalio screen.""" - self._display.show(None) + self._display.root_group = CIRCUITPYTHON_TERMINAL class Clue: # pylint: disable=too-many-instance-attributes, too-many-public-methods From be1c565d5e10d96c0302d548a105c6c00959d10c Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 8 Jan 2024 15:04:57 -0600 Subject: [PATCH 04/12] change import for sphinx --- adafruit_clue.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_clue.py b/adafruit_clue.py index 85d4bbf..84d6a05 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -59,7 +59,7 @@ import audiopwmio import audiocore import touchio -from displayio import CIRCUITPYTHON_TERMINAL +import displayio __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CLUE.git" @@ -155,7 +155,7 @@ def show(self): def show_terminal(self): """Revert to terminalio screen.""" - self._display.root_group = CIRCUITPYTHON_TERMINAL + self._display.root_group = displayio.CIRCUITPYTHON_TERMINAL class Clue: # pylint: disable=too-many-instance-attributes, too-many-public-methods From 31ad24fc1382063ff71502da3ed415de78781da6 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 8 Jan 2024 15:24:03 -0600 Subject: [PATCH 05/12] remove constructor import displayio --- adafruit_clue.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_clue.py b/adafruit_clue.py index 84d6a05..1c6ad8d 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -78,7 +78,6 @@ def __init__( # pylint: disable=too-many-arguments colors: Optional[Tuple[Tuple[int, int, int], ...]] = None, ): # pylint: disable=import-outside-toplevel - import displayio import terminalio from adafruit_display_text import label From d8b97baa823cbbffc2ada37cf1f307b30c6b2fe4 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 7 Oct 2024 09:24:05 -0500 Subject: [PATCH 06/12] 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 6fa3368..8546317 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -126,7 +126,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 4135c7936eb45eb89c684bc6615fa17902d755a9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Thu, 7 Nov 2024 16:19:02 -0600 Subject: [PATCH 07/12] use higher tones in docstring examples --- adafruit_clue.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_clue.py b/adafruit_clue.py index 1c6ad8d..16e339e 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -747,9 +747,9 @@ def start_tone(self, frequency: int): while True: if clue.button_a: - clue.start_tone(523) + clue.start_tone(1600) elif clue.button_b: - clue.start_tone(587) + clue.start_tone(2000) else: clue.stop_tone() """ @@ -779,9 +779,9 @@ def stop_tone(self): while True: if clue.button_a: - clue.start_tone(523) + clue.start_tone(1600) elif clue.button_b: - clue.start_tone(587) + clue.start_tone(2000) else: clue.stop_tone() """ From 0c129367dec34605c32987ef14a8e9d1835a4253 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 13 Nov 2024 11:35:44 -0600 Subject: [PATCH 08/12] iterable touch API --- adafruit_clue.py | 45 ++++++++++++++++++++++++-------------- examples/clue_touch_all.py | 34 ++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 examples/clue_touch_all.py diff --git a/adafruit_clue.py b/adafruit_clue.py index 16e339e..9fcc58a 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -40,7 +40,7 @@ """ try: - from typing import Union, Tuple, Optional + from typing import Union, Tuple, Optional, List except ImportError: pass @@ -48,6 +48,7 @@ import array import math import board +from microcontroller import Pin import digitalio import neopixel import adafruit_apds9960.apds9960 @@ -188,12 +189,13 @@ def __init__(self): self._i2c = board.I2C() # Define touch: - # Initially, self._touches stores the pin used for a particular touch. When that touch is - # used for the first time, the pin is replaced with the corresponding TouchIn object. - # This saves a little RAM over using a separate read-only pin tuple. + # Initially, self._touches is an empty dictionary. When a touch is used + # for the first time, the pin is added as a key to the dictionary, with + # the corresponding TouchIn object added as the value. This saves a + # little RAM by only populating the dictionary as needed. # For example, after `clue.touch_2`, self._touches is equivalent to: - # [board.D0, board.D1, touchio.TouchIn(board.D2)] - self._touches = [board.D0, board.D1, board.D2] + # { board.P2, touchio.TouchIn(board.P2) } + self._touches = {} self._touch_threshold_adjustment = 0 # Define buttons: @@ -240,13 +242,14 @@ def __init__(self): # Create displayio object for passing. self.display = board.DISPLAY - def _touch(self, i: int) -> bool: - if not isinstance(self._touches[i], touchio.TouchIn): - # First time referenced. Get the pin from the slot for this touch - # and replace it with a TouchIn object for the pin. - self._touches[i] = touchio.TouchIn(self._touches[i]) - self._touches[i].threshold += self._touch_threshold_adjustment - return self._touches[i].value + def _touch(self, pin: Pin) -> bool: + touchin = self._touches.get(pin) + if not touchin: + # First time referenced. Make TouchIn object for the pin + touchin = touchio.TouchIn(pin) + touchin.threshold += self._touch_threshold_adjustment + self._touches[pin] = touchin + return touchin.value @property def touch_0(self) -> bool: @@ -267,7 +270,7 @@ def touch_0(self) -> bool: if clue.touch_0: print("Touched pad 0") """ - return self._touch(0) + return self._touch(board.P0) @property def touch_1(self) -> bool: @@ -288,7 +291,7 @@ def touch_1(self) -> bool: if clue.touch_1: print("Touched pad 1") """ - return self._touch(1) + return self._touch(board.P1) @property def touch_2(self) -> bool: @@ -309,7 +312,17 @@ def touch_2(self) -> bool: if clue.touch_2: print("Touched pad 2") """ - return self._touch(2) + return self._touch(board.P2) + + @property + def touch_pins(self) -> List[Pin]: + """A list of all the pins that are set up as touchpad inputs""" + return list(self._touches.keys()) + + @property + def touched(self): + """A list of all the pins that are currently registering a touch""" + return [pin for pin, touchpad in self._touches.items() if touchpad.value] @property def button_a(self) -> bool: diff --git a/examples/clue_touch_all.py b/examples/clue_touch_all.py new file mode 100644 index 0000000..d8b6099 --- /dev/null +++ b/examples/clue_touch_all.py @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + +"""This example prints to the serial console when you touch the capacitive touch pads.""" +import time +import board +from adafruit_clue import clue + + +# You'll need to first use the touchpads individually to register them as active touchpads +# You don't have to use the result though +is_p0_touched = clue.touch_0 # This result can be used if you want +if is_p0_touched: + print("P0/D0 was touched upon startup!") +is_p1_touched = clue.touch_1 +is_p2_touched = clue.touch_2 + + +print("Pads that are currently setup as touchpads:") +print(clue.touch_pins) + +while True: + current_touched = clue.touched + + if current_touched: + print("Touchpads currently registering a touch:") + print(current_touched) + else: + print("No touchpads are currently registering a touch.") + + if all(pad in current_touched for pad in (board.P0, board.P1, board.P2)): + print("This only prints when P0, P1, and P2 are being held at the same time!") + + time.sleep(0.25) From 416938e093083f5b5b0c53bf32f173a6dbba0b5c Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 09/12] 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 eb2e918cc8d053deb551dc72b0f3a9f03ffb93fd Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 11 Feb 2025 16:58:08 -0500 Subject: [PATCH 10/12] Support new version with LSM6DS3TRC --- adafruit_clue.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/adafruit_clue.py b/adafruit_clue.py index 9fcc58a..31d6e29 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -55,6 +55,7 @@ import adafruit_bmp280 import adafruit_lis3mdl import adafruit_lsm6ds.lsm6ds33 +import adafruit_lsm6ds.lsm6ds3trc import adafruit_sht31d import audiobusio import audiopwmio @@ -225,7 +226,10 @@ def __init__(self): # Define sensors: # Accelerometer/gyroscope: - self._accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(self._i2c) + try: + self._accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(self._i2c) + except: + self._accelerometer = adafruit_lsm6ds.lsm6ds3trc.LSM6DS3TRC(self._i2c) # Magnetometer: self._magnetometer = adafruit_lis3mdl.LIS3MDL(self._i2c) From 71ba8ed6f2eeb5b92d3626297a632af0b5cc7ab4 Mon Sep 17 00:00:00 2001 From: Dave Astels Date: Tue, 11 Feb 2025 17:32:09 -0500 Subject: [PATCH 11/12] Add RuntimeException specification --- adafruit_clue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_clue.py b/adafruit_clue.py index 31d6e29..33f55b7 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -228,7 +228,7 @@ def __init__(self): # Accelerometer/gyroscope: try: self._accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(self._i2c) - except: + except RuntimeError: self._accelerometer = adafruit_lsm6ds.lsm6ds3trc.LSM6DS3TRC(self._i2c) # Magnetometer: From 75d15481952ae364404a2aa3a8079972015bb3b5 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 13 May 2025 21:38:33 +0000 Subject: [PATCH 12/12] change to ruff --- .gitattributes | 11 + .pre-commit-config.yaml | 43 +- .pylintrc | 399 ------------------ README.rst | 6 +- adafruit_clue.py | 43 +- docs/api.rst | 3 + docs/conf.py | 8 +- examples/clue_ams_remote.py | 6 +- examples/clue_ams_remote_advanced.py | 24 +- examples/clue_ble_color_patchwork.py | 20 +- examples/clue_display_sensor_data.py | 26 +- examples/clue_height_calculator.py | 5 +- examples/clue_simpletest.py | 12 +- examples/clue_slideshow/clue_slideshow.py | 3 +- examples/clue_spirit_level.py | 2 + examples/clue_temperature_humidity_monitor.py | 5 +- examples/clue_touch_all.py | 4 +- ruff.toml | 105 +++++ 18 files changed, 206 insertions(+), 519 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 00c1d16..343482c 100644 --- a/README.rst +++ b/README.rst @@ -13,9 +13,9 @@ Introduction :target: https://github.com/adafruit/Adafruit_CircuitPython_CLUE/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 A high level library representing all the features of the Adafruit CLUE diff --git a/adafruit_clue.py b/adafruit_clue.py index 33f55b7..2454b78 100644 --- a/adafruit_clue.py +++ b/adafruit_clue.py @@ -40,28 +40,29 @@ """ try: - from typing import Union, Tuple, Optional, List + from typing import List, Optional, Tuple, Union except ImportError: pass -import time import array import math -import board -from microcontroller import Pin -import digitalio -import neopixel +import time + import adafruit_apds9960.apds9960 import adafruit_bmp280 import adafruit_lis3mdl -import adafruit_lsm6ds.lsm6ds33 import adafruit_lsm6ds.lsm6ds3trc +import adafruit_lsm6ds.lsm6ds33 import adafruit_sht31d import audiobusio -import audiopwmio import audiocore -import touchio +import audiopwmio +import board +import digitalio import displayio +import neopixel +import touchio +from microcontroller import Pin __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CLUE.git" @@ -70,7 +71,7 @@ class _ClueSimpleTextDisplay: """Easily display lines of text on CLUE display.""" - def __init__( # pylint: disable=too-many-arguments + def __init__( self, title: Optional[str] = None, title_color: Union[int, Tuple[int, int, int]] = 0xFFFFFF, @@ -79,11 +80,8 @@ def __init__( # pylint: disable=too-many-arguments font: Optional[str] = None, colors: Optional[Tuple[Tuple[int, int, int], ...]] = None, ): - # pylint: disable=import-outside-toplevel - import terminalio - from adafruit_display_text import label - - # pylint: enable=import-outside-toplevel + import terminalio # noqa: PLC0415 + from adafruit_display_text import label # noqa: PLC0415 if not colors: colors = ( @@ -135,9 +133,7 @@ def __getitem__(self, item: int): """Fetch the Nth text line Group""" if len(self._lines) - 1 < item: for _ in range(item - (len(self._lines) - 1)): - self._lines.append( - self.add_text_line(color=self._colors[item % len(self._colors)]) - ) + self._lines.append(self.add_text_line(color=self._colors[item % len(self._colors)])) return self._lines[item] def add_text_line(self, color: Union[int, Tuple[int, int, int]] = 0xFFFFFF): @@ -159,7 +155,7 @@ def show_terminal(self): self._display.root_group = displayio.CIRCUITPYTHON_TERMINAL -class Clue: # pylint: disable=too-many-instance-attributes, too-many-public-methods +class Clue: """Represents a single CLUE.""" # Color variables available for import. @@ -812,10 +808,7 @@ def stop_tone(self): def _normalized_rms(values) -> float: mean_values = int(sum(values) / len(values)) return math.sqrt( - sum( - float(sample - mean_values) * (sample - mean_values) - for sample in values - ) + sum(float(sample - mean_values) * (sample - mean_values) for sample in values) / len(values) ) @@ -884,7 +877,7 @@ def loud_sound(self, sound_threshold: int = 200) -> bool: return self.sound_level > sound_threshold @staticmethod - def simple_text_display( # pylint: disable=too-many-arguments + def simple_text_display( title: Optional[str] = None, title_color: Tuple = (255, 255, 255), title_scale: int = 1, @@ -951,7 +944,7 @@ def simple_text_display( # pylint: disable=too-many-arguments ) -clue = Clue() # pylint: disable=invalid-name +clue = Clue() """Object that is automatically created on import. To use, simply import it from the module: diff --git a/docs/api.rst b/docs/api.rst index 69e2c21..e6b2318 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_clue :members: diff --git a/docs/conf.py b/docs/conf.py index 8546317..960610c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- - # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written 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 = "2020" 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 + " Kattni Rembor" author = "Kattni Rembor" diff --git a/examples/clue_ams_remote.py b/examples/clue_ams_remote.py index 508f2ca..2991d91 100644 --- a/examples/clue_ams_remote.py +++ b/examples/clue_ams_remote.py @@ -12,13 +12,15 @@ """ import time + import adafruit_ble from adafruit_ble.advertising.standard import SolicitServicesAdvertisement from adafruit_ble_apple_media import AppleMediaService + from adafruit_clue import clue # PyLint can't find BLERadio for some reason so special case it here. -radio = adafruit_ble.BLERadio() # pylint: disable=no-member +radio = adafruit_ble.BLERadio() a = SolicitServicesAdvertisement() a.solicited_services.append(AppleMediaService) radio.start_advertising(a) @@ -44,7 +46,7 @@ play_str = "Playing" else: play_str = "Paused" - print("{} - {}, {}".format(ams.title, ams.artist, play_str)) + print(f"{ams.title} - {ams.artist}, {play_str}") # Capacitive touch pad marked 0 goes to the previous track if clue.touch_0: diff --git a/examples/clue_ams_remote_advanced.py b/examples/clue_ams_remote_advanced.py index 1b21ac8..dbf2f97 100644 --- a/examples/clue_ams_remote_advanced.py +++ b/examples/clue_ams_remote_advanced.py @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: 2020 Eva Herrada for Adafruit Industries # SPDX-License-Identifier: MIT -""" This example solicits that apple devices that provide notifications connect to it, initiates +"""This example solicits that apple devices that provide notifications connect to it, initiates pairing, then allows the user to use a CLUE board as a media remote through both the buttons and capacitive touch pads. @@ -16,20 +16,20 @@ """ import time + +import adafruit_ble import board import displayio -from adafruit_display_text import label -import adafruit_ble -from adafruit_ble.advertising.standard import SolicitServicesAdvertisement -from adafruit_ble_apple_media import AppleMediaService -from adafruit_ble_apple_media import UnsupportedCommand from adafruit_bitmap_font import bitmap_font +from adafruit_ble.advertising.standard import SolicitServicesAdvertisement +from adafruit_ble_apple_media import AppleMediaService, UnsupportedCommand from adafruit_display_shapes.rect import Rect -from adafruit_clue import clue +from adafruit_display_text import label +from adafruit_clue import clue # PyLint can't find BLERadio for some reason so special case it here. -radio = adafruit_ble.BLERadio() # pylint: disable=no-member +radio = adafruit_ble.BLERadio() a = SolicitServicesAdvertisement() a.solicited_services.append(AppleMediaService) radio.start_advertising(a) @@ -105,9 +105,7 @@ if not width: width = 1 if ams.duration and ams.playing: - width1 = int( - 210 * ((time.time() - ref_time + ela_time) / float(ams.duration)) - ) + width1 = int(210 * ((time.time() - ref_time + ela_time) / float(ams.duration))) if not width1: width1 = 1 elif not ams.duration: @@ -115,9 +113,7 @@ time_inner = Rect(15, 210, width1, 20, fill=0xFFFFFF) # , outline=0xFFFFFF) group[-2] = time_inner - volume_inner = Rect( - 15, 170, width, 20, fill=0xFFFFFF - ) # , outline=0xFFFFFF) + volume_inner = Rect(15, 170, width, 20, fill=0xFFFFFF) # , outline=0xFFFFFF) group[-1] = volume_inner # Capacitive touch pad marked 0 goes to the previous track diff --git a/examples/clue_ble_color_patchwork.py b/examples/clue_ble_color_patchwork.py index 4b8a561..4f0ec3b 100644 --- a/examples/clue_ble_color_patchwork.py +++ b/examples/clue_ble_color_patchwork.py @@ -8,15 +8,17 @@ advertisement that we find. """ -import time import random +import time + import board import displayio -from adafruit_display_text import label import terminalio from adafruit_ble import BLERadio from adafruit_ble.advertising.adafruit import AdafruitColor from adafruit_display_shapes.rect import Rect +from adafruit_display_text import label + from adafruit_clue import clue MODE_COLOR_SELECT = 0 @@ -62,9 +64,7 @@ def make_white(): def draw_grid(): for i, color in enumerate(nearby_colors): if i < 64: - palette_mapping[i + 2] = ( - color & 0xFFFFFF - ) # Mask 0xFFFFFF to avoid invalid color. + palette_mapping[i + 2] = color & 0xFFFFFF # Mask 0xFFFFFF to avoid invalid color. print(i) print(color) @@ -150,9 +150,7 @@ def change_advertisement(color): left_btn_lbl = label.Label(terminalio.FONT, text="A", color=0x000000) right_btn_lbl = label.Label(terminalio.FONT, text="B", color=0x000000) -left_btn_action = label.Label( - terminalio.FONT, text="Next\nColor", color=0x000000, line_spacing=1 -) +left_btn_action = label.Label(terminalio.FONT, text="Next\nColor", color=0x000000, line_spacing=1) right_btn_action = label.Label(terminalio.FONT, text="Save", color=0x000000) color_select_text_group.append(left_btn_lbl) @@ -239,7 +237,7 @@ def change_advertisement(color): if last_scan_time + SCAN_INTERVAL < now: ble_scan() last_scan_time = now - print("after scan found {} results".format(len(nearby_colors))) + print(f"after scan found {len(nearby_colors)} results") # print(nearby_addresses) draw_grid() @@ -248,9 +246,7 @@ def change_advertisement(color): while clue.proximity >= PROXIMITY_LIMIT: r, g, b, w = clue.color clue.pixel.fill(((r >> 8) & 0xFF, (g >> 8) & 0xFF, (b >> 8) & 0xFF)) - change_advertisement( - ((r & 0xFF00) << 8) + (g & 0xFF00) + ((b >> 8) & 0xFF) - ) + change_advertisement(((r & 0xFF00) << 8) + (g & 0xFF00) + ((b >> 8) & 0xFF)) time.sleep(0.1) clue.white_leds = False diff --git a/examples/clue_display_sensor_data.py b/examples/clue_display_sensor_data.py index 909e9ce..06a60fa 100644 --- a/examples/clue_display_sensor_data.py +++ b/examples/clue_display_sensor_data.py @@ -8,21 +8,19 @@ clue_data = clue.simple_text_display(title="CLUE Sensor Data!", title_scale=2) while True: - clue_data[0].text = "Acceleration: {:.2f} {:.2f} {:.2f} m/s^2".format( - *clue.acceleration - ) + clue_data[0].text = "Acceleration: {:.2f} {:.2f} {:.2f} m/s^2".format(*clue.acceleration) clue_data[1].text = "Gyro: {:.2f} {:.2f} {:.2f} dps".format(*clue.gyro) clue_data[2].text = "Magnetic: {:.3f} {:.3f} {:.3f} uTesla".format(*clue.magnetic) - clue_data[3].text = "Pressure: {:.3f} hPa".format(clue.pressure) - clue_data[4].text = "Altitude: {:.1f} m".format(clue.altitude) - clue_data[5].text = "Temperature: {:.1f} C".format(clue.temperature) - clue_data[6].text = "Humidity: {:.1f} %".format(clue.humidity) - clue_data[7].text = "Proximity: {}".format(clue.proximity) - clue_data[8].text = "Gesture: {}".format(clue.gesture) + clue_data[3].text = f"Pressure: {clue.pressure:.3f} hPa" + clue_data[4].text = f"Altitude: {clue.altitude:.1f} m" + clue_data[5].text = f"Temperature: {clue.temperature:.1f} C" + clue_data[6].text = f"Humidity: {clue.humidity:.1f} %" + clue_data[7].text = f"Proximity: {clue.proximity}" + clue_data[8].text = f"Gesture: {clue.gesture}" clue_data[9].text = "Color: R: {} G: {} B: {} C: {}".format(*clue.color) - clue_data[10].text = "Button A: {}".format(clue.button_a) - clue_data[11].text = "Button B: {}".format(clue.button_b) - clue_data[12].text = "Touch 0: {}".format(clue.touch_0) - clue_data[13].text = "Touch 1: {}".format(clue.touch_1) - clue_data[14].text = "Touch 2: {}".format(clue.touch_2) + clue_data[10].text = f"Button A: {clue.button_a}" + clue_data[11].text = f"Button B: {clue.button_b}" + clue_data[12].text = f"Touch 0: {clue.touch_0}" + clue_data[13].text = f"Touch 1: {clue.touch_1}" + clue_data[14].text = f"Touch 2: {clue.touch_2}" clue_data.show() diff --git a/examples/clue_height_calculator.py b/examples/clue_height_calculator.py index 360c1f6..c6a450e 100755 --- a/examples/clue_height_calculator.py +++ b/examples/clue_height_calculator.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: MIT """Calculate the height of an object. Press button A to reset initial height and then lift the CLUE to find the height.""" + from adafruit_clue import clue # Set to the sea level pressure in hPa at your location for the most accurate altitude measurement. @@ -26,6 +27,6 @@ else: clue.pixel.fill(0) - clue_display[5].text = "Altitude: {:.1f} m".format(clue.altitude) - clue_display[7].text = "Height: {:.1f} m".format(clue.altitude - initial_height) + clue_display[5].text = f"Altitude: {clue.altitude:.1f} m" + clue_display[7].text = f"Height: {clue.altitude - initial_height:.1f} m" clue_display.show() diff --git a/examples/clue_simpletest.py b/examples/clue_simpletest.py index ac1703d..5376ae6 100644 --- a/examples/clue_simpletest.py +++ b/examples/clue_simpletest.py @@ -9,11 +9,11 @@ print("Acceleration: {:.2f} {:.2f} {:.2f} m/s^2".format(*clue.acceleration)) print("Gyro: {:.2f} {:.2f} {:.2f} dps".format(*clue.gyro)) print("Magnetic: {:.3f} {:.3f} {:.3f} uTesla".format(*clue.magnetic)) - print("Pressure: {:.3f} hPa".format(clue.pressure)) - print("Altitude: {:.1f} m".format(clue.altitude)) - print("Temperature: {:.1f} C".format(clue.temperature)) - print("Humidity: {:.1f} %".format(clue.humidity)) - print("Proximity: {}".format(clue.proximity)) - print("Gesture: {}".format(clue.gesture)) + print(f"Pressure: {clue.pressure:.3f} hPa") + print(f"Altitude: {clue.altitude:.1f} m") + print(f"Temperature: {clue.temperature:.1f} C") + print(f"Humidity: {clue.humidity:.1f} %") + print(f"Proximity: {clue.proximity}") + print(f"Gesture: {clue.gesture}") print("Color: R: {} G: {} B: {} C: {}".format(*clue.color)) print("--------------------------------") diff --git a/examples/clue_slideshow/clue_slideshow.py b/examples/clue_slideshow/clue_slideshow.py index 1185df3..826b186 100755 --- a/examples/clue_slideshow/clue_slideshow.py +++ b/examples/clue_slideshow/clue_slideshow.py @@ -7,7 +7,8 @@ Requires the Adafruit CircuitPython Slideshow library!""" -from adafruit_slideshow import SlideShow, PlayBackDirection +from adafruit_slideshow import PlayBackDirection, SlideShow + from adafruit_clue import clue slideshow = SlideShow(clue.display, auto_advance=False) diff --git a/examples/clue_spirit_level.py b/examples/clue_spirit_level.py index 02d075e..b32050a 100755 --- a/examples/clue_spirit_level.py +++ b/examples/clue_spirit_level.py @@ -2,9 +2,11 @@ # # SPDX-License-Identifier: MIT """CLUE Spirit Level Demo""" + import board import displayio from adafruit_display_shapes.circle import Circle + from adafruit_clue import clue display = board.DISPLAY diff --git a/examples/clue_temperature_humidity_monitor.py b/examples/clue_temperature_humidity_monitor.py index c1090fd..a0f7b7d 100755 --- a/examples/clue_temperature_humidity_monitor.py +++ b/examples/clue_temperature_humidity_monitor.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT """Monitor customisable temperature and humidity ranges, with an optional audible alarm tone.""" + from adafruit_clue import clue # Set desired temperature range in degrees Celsius. @@ -26,8 +27,8 @@ temperature = clue.temperature humidity = clue.humidity - clue_display[3].text = "Temp: {:.1f} C".format(temperature) - clue_display[5].text = "Humi: {:.1f} %".format(humidity) + clue_display[3].text = f"Temp: {temperature:.1f} C" + clue_display[5].text = f"Humi: {humidity:.1f} %" if temperature < min_temperature: clue_display[3].color = clue.BLUE diff --git a/examples/clue_touch_all.py b/examples/clue_touch_all.py index d8b6099..f3a8048 100644 --- a/examples/clue_touch_all.py +++ b/examples/clue_touch_all.py @@ -2,10 +2,12 @@ # SPDX-License-Identifier: MIT """This example prints to the serial console when you touch the capacitive touch pads.""" + import time + import board -from adafruit_clue import clue +from adafruit_clue import clue # You'll need to first use the touchpads individually to register them as active touchpads # You don't have to use the result though diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..36332ff --- /dev/null +++ b/ruff.toml @@ -0,0 +1,105 @@ +# 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 +] + +[format] +line-ending = "lf"