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
12 changes: 4 additions & 8 deletions lib/apds9960/apds9960/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ def set_mode(self, mode, enable=True):

# change bit(s) in ENABLE register */
if mode == APDS9960_MODE_ALL:
if enable:
reg_val = 0x7F
else:
reg_val = 0x00
reg_val = 0x7F if enable else 0x00
else:
if enable:
reg_val |= 1 << mode
Expand Down Expand Up @@ -199,10 +196,9 @@ def gesture(self):
self.gesture_data_.total_gestures += 1

# filter and process gesture data, decode near/far state
if self.process_gesture_data():
if self.decode_gesture():
# ***TODO: U-Turn Gestures
pass
if self.process_gesture_data() and self.decode_gesture():
# ***TODO: U-Turn Gestures
pass

# reset data
self.gesture_data_.index = 0
Expand Down
5 changes: 1 addition & 4 deletions lib/bq27441/bq27441/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,7 @@ def execute_control_word(self, function):
sub_command_msb = function >> 8
sub_command_lsb = function & 0x00FF
command = [sub_command_lsb, sub_command_msb]
if self._write_reg(0, command, 2):
return True

return False
return bool(self._write_reg(0, command, 2))

# Extended Data Cmds
# Issue a block_data_control() command to enable block data access
Expand Down
2 changes: 1 addition & 1 deletion lib/mcp23009e/examples/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

print("Configuration des boutons...")
for btn_pin in btn_mapping.keys():
for btn_pin in btn_mapping:
mcp.setup(btn_pin, MCP23009_DIR_INPUT, pullup=MCP23009_PULLUP)
print("✓ Configuration terminée\n")

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ select = [
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"SIM", # flake8-simplify
"T10", # flake8-debugger
"PERF", # Perflint
"T20", # flake8-print: no print() in production code
Expand All @@ -86,7 +87,8 @@ ignore = [
"PLW2901", # overwriting loop variable
"RUF012", # mutable class variable
"RUF100", # unused noqa
"SIM101", # merge isinstance calls
"SIM101", # merge isinstance calls (micropython compat)
"SIM105", # contextlib.suppress not available in micropython
"W191", # tab-indent, redundant when using formatter
]

Expand Down
36 changes: 17 additions & 19 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ def test_method_calls_exist_in_driver(self, driver_dir, example_path):
return # Covered by test_syntax_valid
driver_imports = set()
for node in ast.walk(tree):
if isinstance(node, ast.ImportFrom):
if node.module and any(
part in driver_dir.name.replace("-", "_")
for part in (node.module.split(".")[0],)
):
for alias in node.names:
driver_imports.add(alias.asname or alias.name)
if isinstance(node, ast.ImportFrom) and node.module and any(
part in driver_dir.name.replace("-", "_")
for part in (node.module.split(".")[0],)
):
for alias in node.names:
driver_imports.add(alias.asname or alias.name)

if not driver_imports:
pytest.skip(f"No driver import found in {example_path.name}")
Expand All @@ -132,18 +131,17 @@ def test_method_calls_exist_in_driver(self, driver_dir, example_path):
# is assigned from a driver constructor
driver_vars = set()
for node in ast.walk(tree):
if isinstance(node, ast.Assign):
if isinstance(node.value, ast.Call):
func = node.value.func
func_name = None
if isinstance(func, ast.Name):
func_name = func.id
elif isinstance(func, ast.Attribute):
func_name = func.attr
if func_name in driver_imports:
for target in node.targets:
if isinstance(target, ast.Name):
driver_vars.add(target.id)
if isinstance(node, ast.Assign) and isinstance(node.value, ast.Call):
func = node.value.func
func_name = None
if isinstance(func, ast.Name):
func_name = func.id
elif isinstance(func, ast.Attribute):
func_name = func.attr
if func_name in driver_imports:
for target in node.targets:
if isinstance(target, ast.Name):
driver_vars.add(target.id)

if not driver_vars:
pytest.skip(
Expand Down
Loading