Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/apds9960/apds9960/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class APDS9960InvalidDevId(ValueError):
def __init__(self, id, valid_ids):
def __init__(self, device_id, valid_ids):
Exception.__init__(
self,
"Device id 0x{} is not a valid one (valid: {})!".format(
format(id, "02x"),
format(device_id, "02x"),
Comment on lines 1 to +6
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APDS9960InvalidDevId.__init__ renamed the parameter from id to device_id. If any external code instantiates this exception using the id= keyword, it will now fail. Consider accepting the old keyword as an alias (with a deprecation note) or documenting this as an intentional API break.

Copilot uses AI. Check for mistakes.
", ".join(["0x{}".format(format(i, "02x")) for i in valid_ids]),
),
)
Expand Down
6 changes: 3 additions & 3 deletions lib/bq27441/bq27441/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ def reset(self):
def soft_reset(self):
return self.execute_control_word(BQ27441_CONTROL_SOFT_RESET)

# Read a 16 - bit command word from the BQ27441-G1A, def format = little endian int16
def read_word(self, sub_address, format="<h"):
# Read a 16-bit command word from the BQ27441-G1A, default fmt = little-endian int16
def read_word(self, sub_address, fmt="<h"):
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_word() renamed its second parameter from format to fmt. This avoids shadowing the builtin, but it is a breaking change for any callers using the format= keyword. Consider keeping backward compatibility (e.g., accept format via **kwargs/alias with a deprecation path) or making this an explicitly private helper if it’s not intended as public API.

Suggested change
def read_word(self, sub_address, fmt="<h"):
def read_word(self, sub_address, fmt="<h", **kwargs):
# Backward compatibility: accept legacy 'format=' keyword argument
if "format" in kwargs:
fmt = kwargs["format"]

Copilot uses AI. Check for mistakes.
data = bytes(self._read_reg(sub_address, 2))
return struct.unpack(format, data)[0]
return struct.unpack(fmt, data)[0]

# Read a 16 - bit subcommand() from the BQ27441-G1A's control()
def read_control_word(self, function):
Expand Down
4 changes: 2 additions & 2 deletions lib/ism330dl/examples/static_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# -------------------------------------------------

while True:
dir = imu.orientation()
direction = imu.orientation()

print("Orientation: {}".format(dir))
print("Orientation: {}".format(direction))

sleep_ms(500)
2 changes: 1 addition & 1 deletion lib/lis2mdl/examples/tilt_compensated_heading.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def pitch_roll_from_accel(ax, ay, az):
accel = imu.acceleration_g()
ax, ay, az = accel

heading = mag.heading_with_tilt_compensation(lambda: accel)
heading = mag.heading_with_tilt_compensation(lambda a=accel: a)
pitch_deg, roll_deg = pitch_roll_from_accel(ax, ay, az)
direction = mag.direction_label(heading)

Expand Down
2 changes: 1 addition & 1 deletion lib/ssd1327/examples/framebuf_scroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
display.show()
sleep(1)

for i in range(2):
for _ in range(2):
display.scroll(0, 16) # framebuf.scroll
display.show()
sleep(1)
2 changes: 1 addition & 1 deletion lib/ssd1327/examples/random_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# random pixels (slow)
# note: urandom not available on all devices

for i in range(256):
for _ in range(256):
x = uos.urandom(1)[0] // 2
y = uos.urandom(1)[0] // 2
display.pixel(x, y, 15)
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ target-version = "py37"

[tool.ruff.lint]
select = [
"A", # flake8-builtins: prevent shadowing builtins
"ASYNC", # flake8-async
"B", # flake8-bugbear: common bug patterns
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"DTZ", # flake8-datetimez
Expand All @@ -60,14 +62,14 @@ select = [
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"T10", # flake8-debugger
"PERF", # Perflint
"T20", # flake8-print: no print() in production code
"TCH", # flake8-type-checking
"W", # pycodestyle
"YTT", # flake8-2020
]
ignore = [
"E501", # line length, recommended to disable
"E722", # bare except
"E741", # 'l' is currently widely used
"F401", # unused import (wildcard re-exports)
"F403", # wildcard import
Expand Down Expand Up @@ -105,6 +107,7 @@ max-statements = 166
# manifest.py files are evaluated with some global names pre-defined
"**/manifest.py" = ["F821"]
"**/examples/*.py" = ["T20", "N806"]
"lib/mcp23009e/examples/i2c_scan.py" = ["PERF203"]
"tests/**/*.py" = ["T20"]

[tool.ruff.format]
Expand Down
4 changes: 2 additions & 2 deletions tests/runner/mpremote_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ def run_raw_script(self, script, mount_dir=None):
last_line = lines[-1] if lines else ""
try:
return json.loads(last_line)
except json.JSONDecodeError:
except json.JSONDecodeError as err:
full = "\n".join(lines)
raise RuntimeError(
f"Script did not produce valid JSON result.\nFull output:\n{full}"
)
) from err

def scan_bus(self, i2c_config):
"""Scan I2C bus and return list of addresses."""
Expand Down
Loading