Conversation
|
Hey there @tuya, @zlinoliver, @METISU, @frenck, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Will do some performance testing |
|
Hmm Not starting up |
|
The websocket can't serialize the states with the mappingproxytype |
|
minor issue 🤣 I will be very surprised if the tests pass (they don't). |
| state_dict = None | ||
| if state: | ||
| state_dict = async_redact_data(state.as_dict(), REDACTED_STATE) | ||
| state_dict = cast(dict, async_redact_data(state.as_dict(), REDACTED_STATE)) |
There was a problem hiding this comment.
I think the typing changes in cc6b0cc are wrong. async_redact_data is returning a dict, not a MappingProxyType, so the cast here is papering over a bug in async_redact_data IMO.
There was a problem hiding this comment.
async_redact_data will convert any type inheriting from Mapping to a dict. It's typed to have input = output type.
Let me see if I can fix that.
There was a problem hiding this comment.
Initial attempt gives me an error.
@overload
def async_redact_data(data: Mapping, to_redact: Iterable[Any]) -> dict:
...
@overload
def async_redact_data(data: T, to_redact: Iterable[Any]) -> T:
...homeassistant/components/diagnostics/util.py:15: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Found 1 error in 1 file (checked 2 source files)
|
Argh so this is not a trivial issue to fix because the JSONEncoder in Python is hard coded to check |
|
Pulling out the Tuya change into a new PR for the hot fix as this change will be a bit more elaborate. |
|
Tuya PR #65708 |
|
That looks like it will be more performant as well 👍 Testing now.... |
|
So far so good.. 👍 |
|
I suggest we adopt ReadOnlyDict in future PRs in all places where we use MappingProxy |

Breaking change
Proposed change
State objects cache their
as_dictoutput. @olle69 noticed that the Tuya diagnostics was mutating this, impacting the cache.This PR makes it immutable and fixes Tuya. Homekit Controller also mutated the dict, but first passed it through redact_data which makes a copy.
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: