fix: operator precedence bug with walrus operator in cli.py command ex… #2891
ci.yml
on: pull_request
Matrix: test
Lint Commit Messages
13s
lint
14s
Build Package
8s
Test Semantic Release
48s
release
Annotations
1 error and 3 warnings
|
Lint Commit Messages
You have commit messages with errors
⧗ input: Fix operator precedence bug with walrus operator in cli.py command execution
## Description
There is a critical operator precedence bug in the `command` function inside `roborock/cli.py` affecting `B01_Q10` devices (and potentially others using the same logic).
Currently, the code reads:
`if cmd_value := B01_Q10_DP.from_any_optional(cmd) is None:`
Because the `is` operator binds tighter than the walrus operator (`:=`), Python evaluates `(B01_Q10_DP.from_any_optional(cmd) is None)` first.
If a valid command is passed, this evaluates to `False`, and the boolean `False` is assigned to `cmd_value`. The `if` block is then skipped, and `cmd_value` (`False`) is passed to `command_trait.send()`.
This results in a crash shortly after:
`AttributeError: 'bool' object has no attribute 'code'`
## Fix
Adding parentheses around the assignment expression fixes the evaluation order:
`if (cmd_value := B01_Q10_DP.from_any_optional(cmd)) is None:`
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
|
|
lint
Node.js 20 actions are deprecated. The following actions are running on Node.js 20 and may not work as expected: actions/cache@v4. Actions will be forced to run with Node.js 24 by default starting June 2nd, 2026. Node.js 20 will be removed from the runner on September 16th, 2026. Please check if updated versions of these actions are available that support Node.js 24. To opt into Node.js 24 now, set the FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true environment variable on the runner or in your workflow file. Once Node.js 24 becomes the default, you can temporarily opt out by setting ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
|
|
test (3.11)
Node.js 20 actions are deprecated. The following actions are running on Node.js 20 and may not work as expected: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea. Actions will be forced to run with Node.js 24 by default starting June 2nd, 2026. Node.js 20 will be removed from the runner on September 16th, 2026. Please check if updated versions of these actions are available that support Node.js 24. To opt into Node.js 24 now, set the FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true environment variable on the runner or in your workflow file. Once Node.js 24 becomes the default, you can temporarily opt out by setting ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
|
|
test (3.14)
Node.js 20 actions are deprecated. The following actions are running on Node.js 20 and may not work as expected: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea. Actions will be forced to run with Node.js 24 by default starting June 2nd, 2026. Node.js 20 will be removed from the runner on September 16th, 2026. Please check if updated versions of these actions are available that support Node.js 24. To opt into Node.js 24 now, set the FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true environment variable on the runner or in your workflow file. Once Node.js 24 becomes the default, you can temporarily opt out by setting ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
|