Skip to content

Commit d64251b

Browse files
committed
pylint fixes
1 parent 93c4502 commit d64251b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Espresso_Water_Meter/code.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import time
1010
import os
11+
import ssl
1112
import microcontroller
1213
import supervisor
13-
import ssl
1414
import socketpool
1515
import wifi
1616
import board
@@ -23,8 +23,6 @@
2323
import adafruit_requests
2424
import adafruit_max1704x
2525

26-
27-
2826
# Initialize the power pin for the sensor
2927
sensor_power = digitalio.DigitalInOut(board.A2)
3028
sensor_power.direction = digitalio.Direction.OUTPUT
@@ -75,6 +73,7 @@ def power_sensor_off():
7573

7674
def parse_time(time_str):
7775
"""Convert time string (HH:MM format) to hours and minutes."""
76+
# pylint: disable=redefined-outer-name
7877
parts = time_str.split(':')
7978
return int(parts[0]), int(parts[1])
8079

@@ -121,7 +120,9 @@ def set_pixel_color(distance):
121120
avg_distance = get_average_distance()
122121

123122
if avg_distance is not None:
123+
124124
if avg_distance >= 22:
125+
# pylint: disable=invalid-name
125126
avg_distance = 22
126127
print(f"Average distance: {avg_distance:.1f} cm")
127128
# Set color based on average distance
@@ -134,6 +135,7 @@ def set_pixel_color(distance):
134135

135136
# Try connecting to WiFi
136137
try:
138+
137139
print("Connecting to %s" % os.getenv("CIRCUITPY_WIFI_SSID"))
138140
# Show pink while attempting to connect
139141
pixel.fill(PINK)
@@ -142,6 +144,7 @@ def set_pixel_color(distance):
142144
# Show cyan on successful connection
143145
pixel.fill(CYAN)
144146
time.sleep(1) # Brief pause to show the connection success
147+
# pylint: disable=broad-except
145148
except Exception as e:
146149
print("Failed to connect to WiFi. Error:", e, "\nBoard will hard reset in 30 seconds.")
147150
pixel.fill(OFF)
@@ -174,6 +177,7 @@ def set_pixel_color(distance):
174177
aio_username = os.getenv("ADAFRUIT_AIO_USERNAME")
175178
aio_key = os.getenv("ADAFRUIT_AIO_KEY")
176179
timezone = os.getenv("TIMEZONE")
180+
# pylint: disable=line-too-long
177181
TIME_URL = f"https://io.adafruit.com/api/v2/{aio_username}/integrations/time/strftime?x-aio-key={aio_key}&tz={timezone}"
178182
TIME_URL += "&fmt=%25Y-%25m-%25d+%25H%3A%25M%3A%25S.%25L+%25j+%25u+%25z+%25Z"
179183

@@ -222,6 +226,7 @@ def set_pixel_color(distance):
222226
time.sleep(DISPLAY_DURATION)
223227

224228
# Use normal check interval during operating hours
229+
# # pylint: disable=invalid-name
225230
sleep_seconds = SLEEP_DURATION
226231
print(f"Next check in {NORMAL_CHECK_MINUTES} minutes")
227232
else:
@@ -245,6 +250,7 @@ def set_pixel_color(distance):
245250

246251
response.close()
247252

253+
# pylint: disable=broad-except
248254
except Exception as e:
249255
print("Failed to get or send data, or connect. Error:", e,
250256
"\nBoard will hard reset in 30 seconds.")
@@ -255,13 +261,15 @@ def set_pixel_color(distance):
255261
else:
256262
print("Failed to get valid distance readings")
257263
pixel.fill(OFF)
264+
# pylint: disable=invalid-name
258265
sleep_seconds = SLEEP_DURATION # Use normal interval if we couldn't get readings
259266

260267
# Prepare for deep sleep
261-
pixel.brightness = 0 # Turn off NeoPixel
262268
power_sensor_off() # Make sure sensor is powered off before sleep
269+
pixel.brightness = 0 # Turn off NeoPixel
263270

264271
# Flush the serial output before sleep
272+
# pylint: disable=pointless-statement
265273
supervisor.runtime.serial_bytes_available
266274
time.sleep(0.05)
267275

0 commit comments

Comments
 (0)