Skip to content

fix: Reverts the V1 image parser monkey-patch - #949

Open
allenporter wants to merge 1 commit into
Python-roborock:mainfrom
allenporter:investigate_issue_181447
Open

fix: Reverts the V1 image parser monkey-patch#949
allenporter wants to merge 1 commit into
Python-roborock:mainfrom
allenporter:investigate_issue_181447

Conversation

@allenporter

@allenporter allenporter commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Reverts the V1 image parser monkey-patch introduced in #902.

Fixes downstream issue home-assistant/core#181447

Background

In #902, _AdjacencyAwareRoborockImageParser was introduced to apply deterministic adjacent room coloring to V1 maps to match the new Q10 map styling. During the initial review of #902, we noted reservations about monkey-patching the upstream library's internal member (RoborockMapDataParser._image_parser) and mutating the read-only palette cache in place, but accepted it to avoid blocking progress on Q10 map support.

As anticipated, coupling directly to internal, undocumented implementation details of vacuum-map-parser-roborock proved brittle. When upstream added support for removed_map to RoborockImageParser.parse() in 0.1.5, the rigid argument list in our subclass caused environments running 0.1.4 to crash during coordinator map updates:

TypeError: RoborockImageParser.parse() takes 5 positional arguments but 6 were given

Changes

Remove monkey-patching entirely: Drop _AdjacencyAwareRoborockImageParser and restore standard, unpatched instantiation of RoborockMapDataParser.
Remove palette mutation: Eliminate in-place dictionary mutations and the associated threading.Lock().
Preserve Q10 support: Q10 map rendering is completely independent and unaffected by this change. It continues to use room_colors.py directly within B01Q10MapParser as designed.
If adjacent room recoloring for V1 maps is desired in the future, it should be proposed upstream in vacuum-map-parser-roborock where it can be supported cleanly via public APIs rather than patched into library internals.

Validation

Verified map tests pass against both vacuum-map-parser-roborock==0.1.4 and 0.1.5.
All Q10 map parser and rendering tests pass (70 passed).
Full pre-commit test and lint suite passes cleanly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is narrowly scoped, matches the stated root cause, and the argument-forwarding approach safely restores compatibility across the affected dependency versions.

Pull request overview

This PR fixes compatibility with multiple vacuum-map-parser-roborock versions by making the internal _AdjacencyAwareRoborockImageParser.parse() override forward unknown/extra arguments to the upstream parser instead of explicitly passing a removed_map positional argument that older versions don’t accept.

Changes:

  • Update _AdjacencyAwareRoborockImageParser.parse() to accept *args, **kwargs instead of a hard-coded removed_map parameter.
  • Forward the extra arguments to super().parse(...) to avoid TypeError on vacuum-map-parser-roborock<=0.1.4 while supporting >=0.1.5 and future additions.
File summaries
File Description
roborock/map/map_parser.py Makes the image parser override argument-forwarding tolerant to upstream signature changes (removed_map and future params).
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Reverts the V1 image parser monkey-patch introduced in Python-roborock#902.

Fixes home-assistant/core#181447
@allenporter
allenporter force-pushed the investigate_issue_181447 branch from 3b17fa2 to 770d407 Compare September 7, 2026 22:24
@allenporter allenporter changed the title fix: forward image parser arguments to support multiple vacuum-map-parser versions fix: Reverts the V1 image parser monkey-patch Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants