From dde2ed7cb106640f822c3cd43a7b5ef361778728 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 5 Nov 2021 02:53:43 -0400 Subject: [PATCH 1/2] Linted --- adafruit_featherwing/alphanum_featherwing.py | 2 +- adafruit_featherwing/gps_featherwing.py | 3 +-- adafruit_featherwing/matrix_featherwing.py | 2 +- adafruit_featherwing/sevensegment_featherwing.py | 2 +- examples/featherwing_keyboard_featherwing.py | 15 +++++++++------ examples/featherwing_tft24_simpletest.py | 15 +++++++++------ examples/featherwing_tft35_simpletest.py | 14 ++++++++------ 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/adafruit_featherwing/alphanum_featherwing.py b/adafruit_featherwing/alphanum_featherwing.py index c458641..aa798c9 100755 --- a/adafruit_featherwing/alphanum_featherwing.py +++ b/adafruit_featherwing/alphanum_featherwing.py @@ -15,7 +15,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" import board -import adafruit_ht16k33.segments as segments +from adafruit_ht16k33 import segments from adafruit_featherwing.led_segments import Segments diff --git a/adafruit_featherwing/gps_featherwing.py b/adafruit_featherwing/gps_featherwing.py index 1b43153..5a924a0 100644 --- a/adafruit_featherwing/gps_featherwing.py +++ b/adafruit_featherwing/gps_featherwing.py @@ -36,8 +36,7 @@ def __init__(self, update_period=1000, baudrate=9600): if update_period < 250: raise ValueError("Update Frequency be at least 250 milliseconds") timeout = update_period // 1000 + 2 - if timeout < 3: - timeout = 3 + timeout = max(timeout, 3) self._uart = busio.UART(board.TX, board.RX, baudrate=baudrate, timeout=timeout) self._gps = adafruit_gps.GPS(self._uart, debug=False) diff --git a/adafruit_featherwing/matrix_featherwing.py b/adafruit_featherwing/matrix_featherwing.py index 066525e..e671ab6 100755 --- a/adafruit_featherwing/matrix_featherwing.py +++ b/adafruit_featherwing/matrix_featherwing.py @@ -16,7 +16,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" import board -import adafruit_ht16k33.matrix as matrix +from adafruit_ht16k33 import matrix from adafruit_featherwing.auto_writeable import AutoWriteable diff --git a/adafruit_featherwing/sevensegment_featherwing.py b/adafruit_featherwing/sevensegment_featherwing.py index c685e8d..6474472 100755 --- a/adafruit_featherwing/sevensegment_featherwing.py +++ b/adafruit_featherwing/sevensegment_featherwing.py @@ -15,7 +15,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" import board -import adafruit_ht16k33.segments as segments +from adafruit_ht16k33 import segments from adafruit_featherwing.led_segments import Segments diff --git a/examples/featherwing_keyboard_featherwing.py b/examples/featherwing_keyboard_featherwing.py index 643f443..fc1fa58 100644 --- a/examples/featherwing_keyboard_featherwing.py +++ b/examples/featherwing_keyboard_featherwing.py @@ -20,13 +20,16 @@ kbd_featherwing.neopixel[0] = 0x002244 try: - f = open("/sd/tft_featherwing.txt", "w") - f.write("Blinka\nBlackberry Q10 Keyboard") - f.close() + with open( # pylint: disable=unspecified-encoding + "/sd/tft_featherwing.txt", "w" + ) as f: + f.write("Blinka\nBlackberry Q10 Keyboard") + + with open( # pylint: disable=unspecified-encoding + "/sd/tft_featherwing.txt", "r" + ) as f: + print(f.read()) - f = open("/sd/tft_featherwing.txt", "r") - print(f.read()) - f.close() except OSError as error: print("Unable to write to SD Card.") diff --git a/examples/featherwing_tft24_simpletest.py b/examples/featherwing_tft24_simpletest.py index 7f11eac..196c6aa 100644 --- a/examples/featherwing_tft24_simpletest.py +++ b/examples/featherwing_tft24_simpletest.py @@ -13,13 +13,16 @@ tft_featherwing = tft_featherwing_24.TFTFeatherWing24() try: - f = open("/sd/tft_featherwing.txt", "w") - f.write("Blinka\nBlackberry Q10 Keyboard") - f.close() + with open( # pylint: disable=unspecified-encoding + "/sd/tft_featherwing.txt", "w" + ) as f: + f.write("Blinka\nBlackberry Q10 Keyboard") + + with open( # pylint: disable=unspecified-encoding + "/sd/tft_featherwing.txt", "r" + ) as f: + print(f.read()) - f = open("/sd/tft_featherwing.txt", "r") - print(f.read()) - f.close() except OSError as error: print("Unable to write to SD Card.") diff --git a/examples/featherwing_tft35_simpletest.py b/examples/featherwing_tft35_simpletest.py index 475073a..d23f956 100644 --- a/examples/featherwing_tft35_simpletest.py +++ b/examples/featherwing_tft35_simpletest.py @@ -13,13 +13,15 @@ tft_featherwing = tft_featherwing_35.TFTFeatherWing35() try: - f = open("/sd/tft_featherwing.txt", "w") - f.write("Blinka\nBlackberry Q10 Keyboard") - f.close() + with open( # pylint: disable=unspecified-encoding + "/sd/tft_featherwing.txt", "w" + ) as f: + f.write("Blinka\nBlackberry Q10 Keyboard") - f = open("/sd/tft_featherwing.txt", "r") - print(f.read()) - f.close() + with open( # pylint: disable=unspecified-encoding + "/sd/tft_featherwing.txt", "r" + ) as f: + print(f.read()) except OSError as error: print("Unable to write to SD Card.") From 6aa117517d5ff1907b00e3108c34726c17fa2021 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 5 Nov 2021 15:58:14 -0400 Subject: [PATCH 2/2] Removed unspecified-encoding disable --- examples/featherwing_keyboard_featherwing.py | 8 ++------ examples/featherwing_tft24_simpletest.py | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/examples/featherwing_keyboard_featherwing.py b/examples/featherwing_keyboard_featherwing.py index fc1fa58..5e0b217 100644 --- a/examples/featherwing_keyboard_featherwing.py +++ b/examples/featherwing_keyboard_featherwing.py @@ -20,14 +20,10 @@ kbd_featherwing.neopixel[0] = 0x002244 try: - with open( # pylint: disable=unspecified-encoding - "/sd/tft_featherwing.txt", "w" - ) as f: + with open("/sd/tft_featherwing.txt", "w") as f: f.write("Blinka\nBlackberry Q10 Keyboard") - with open( # pylint: disable=unspecified-encoding - "/sd/tft_featherwing.txt", "r" - ) as f: + with open("/sd/tft_featherwing.txt", "r") as f: print(f.read()) except OSError as error: diff --git a/examples/featherwing_tft24_simpletest.py b/examples/featherwing_tft24_simpletest.py index 196c6aa..2aee653 100644 --- a/examples/featherwing_tft24_simpletest.py +++ b/examples/featherwing_tft24_simpletest.py @@ -13,14 +13,10 @@ tft_featherwing = tft_featherwing_24.TFTFeatherWing24() try: - with open( # pylint: disable=unspecified-encoding - "/sd/tft_featherwing.txt", "w" - ) as f: + with open("/sd/tft_featherwing.txt", "w") as f: f.write("Blinka\nBlackberry Q10 Keyboard") - with open( # pylint: disable=unspecified-encoding - "/sd/tft_featherwing.txt", "r" - ) as f: + with open("/sd/tft_featherwing.txt", "r") as f: print(f.read()) except OSError as error: