-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make UnitSystem
a frozen dataclass
#140954
Make UnitSystem
a frozen dataclass
#140954
Conversation
UnitSystem
a frozen dataclass
Do we need to search for published custom integrations that would be affected by this change? We've seen before that custom integrations do weird things. |
I have tried to think of it, I can't be 100% sure, but I think if a custom integration modify the unit system it will already have undesired effects since this is the base for unit conversions and it globally used by all sensors so I assume this was only a bad pattern we used in tests. |
Yes, it would already be bad, but it could be a hidden bug, while now it will raise an error immediately if the integration tries to modify the instance. We should probably at least publish a dev blog about the change. |
Yes, we should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Proposed change
CI was failing since tests were modifying the
UnitSystem
metric constant which affected all tests if it is not set back to the original values after the test is finished, discussion about it suggested to make it a frozen data class.Background: #140295, #140323
CI tests fixed already at: #140376, #140372, #140371, #140366, #140365, #140358, #140357 which can be seen that CI pass here for all tests.
With a frozen data class if a test modify the
UnitSystem
constant it fails (example of reverting #140365 locally):Type of change
Additional information
UnitSystem
class and their implications developers.home-assistant#2618Checklist
ruff format 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
.To help with the load of incoming pull requests: