refactor: enable stricter ruff lints and broad exception checking - #956
Merged
allenporter merged 1 commit intoSep 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
roborock/util.py has an unresolved typing error, and the CLI’s file-wide BLE001 opt-out should be narrowed.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR tightens Ruff linting and applies related code-quality and typing cleanups.
Changes:
- Enables additional Ruff rule families with scoped ignores.
- Updates exception handling, chaining, and type-ignore annotations.
- Cleans up comprehensions,
zip()usage, fixtures, and defaults.
File summaries
| File | Changes |
|---|---|
tests/test_web_api.py |
Removes redundant fixture body. |
tests/fixtures/pahomqtt_fixtures.py |
Adds warning stack levels. |
tests/fixtures/local_async_fixtures.py |
Adds warning stack level. |
tests/data/test_code_mappings.py |
Renames a shadowing parameter. |
roborock/util.py |
Removes a type ignore from list padding; typing issue remains. |
roborock/testing/v1_simulator.py |
Annotates intentional broad catches. |
roborock/protocols/b01_q7_protocol.py |
Adds exception chaining. |
roborock/protocols/a01_protocol.py |
Adds exception chaining. |
roborock/protocol.py |
Updates typing directives and comprehensions. |
roborock/mqtt/roborock_session.py |
Annotates reconnect exception handling. |
roborock/map/b01_q10_map_parser.py |
Clarifies zip() strictness and range usage. |
roborock/map/b01_grid_layers.py |
Makes coordinate zipping strict. |
roborock/devices/transport/local_channel.py |
Annotates keep-alive exception handling. |
roborock/devices/traits/v1/rooms.py |
Annotates fallback exception handling. |
roborock/devices/traits/v1/clean_summary.py |
Annotates conversion fallback handling. |
roborock/devices/traits/__init__.py |
Suppresses an intentional abstract-base warning. |
roborock/devices/rpc/b01_q7_channel.py |
Annotates response parsing exceptions. |
roborock/device_features.py |
Removes an unnecessary type ignore. |
roborock/data/v1/v1_code_mappings.py |
Narrows a type-ignore annotation. |
roborock/data/containers.py |
Simplifies exception handling and defaults. |
roborock/data/code_mappings.py |
Narrows a type-ignore annotation. |
roborock/cli.py |
Updates exception handling and typing directives; file-wide BLE001 opt-out should be narrowed. |
roborock/broadcast_protocol.py |
Annotates packet parsing exceptions. |
pyproject.toml |
Enables expanded Ruff rules and scoped ignores. |
Review details
Suppressed comments (1)
roborock/cli.py:25
- This module-level opt-out disables
BLE001for every broad catch in the CLI and for any future one, so the new lint no longer checks this file at all. Please remove the file-wide directive and annotate only the specific command/parser boundaries that intentionally continue after arbitrary failures; that keeps accidental broad catches visible to the stricter configuration.
# ruff: noqa: BLE001
- Files reviewed: 24/24 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Lash-L
approved these changes
Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates the Ruff configuration and codebase to align with repository engineering guidelines (AGENTS.md):
Eliminate Global Ignores:
lint.ignore = [].F403toper-file-ignoresexplicitly only on specific__init__.pymodules that perform wildcard re-exports.E741to an inline# noqa: E741incontainers.pywherelis a wire payload field.Broad Exception Checking (
BLE001):BLE(flake8-blind-except) tolint.select.# ruff: noqa: BLE001opt-out forroborock/cli.py.except BaseException:withexcept Exception:in CLI debug parser.# noqa: BLE001annotations on loop supervisors and trait query fallbacks.Enable High-Value Rule Sets:
B(bugbear),C4(comprehensions),PIE(flake8-pie),A(builtins),PGH(pygrep-hooks),W(pycodestyle warnings), and clean conventions (YTT,FA,ICN,ISC).raise ... from err(B904),strictparameter inzip()(B905), and type ignore tags (PGH003).TODOcomment inpyproject.tomlto enableASYNC(flake8-async) in a dedicated follow-up PR.Testing
uv run ruff check roborock testspasses.uv run pre-commit run --all-filespasses.uv run pytestpasses (983 tests, 92 snapshots).