Prevent partial custom component overlays #21070
Merged
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 will force platforms to be resolved based off the component path, if it exists.
Today, if you want, you can override the Hue light platform, but not the other parts of the Hue integration. If a future update evolves the Hue component, removing or changing internal methods that the custom platform relied upon, the custom platform will start failing (like this report).
To avoid this, we're going to no longer allow custom components to be partial overlays (just a platform). Instead, if you want to override a built-in platform, you will need to override the whole component.
This is enforced by first resolving the platform as a component, and if it exists, limiting the lookup path to the component path.
Example: if I look up the
hue
component, and it is provided by a custom component, then all platform lookups will also be looked up in the custom component dir. The same works the other way around, if a user would only try to overridehue/light.py
but nothue/__init__.py
, the custom platform will be ignored.Breaking change: Custom platforms that override a built-in platform that has a component, should now also include the component in the
custom_components/
folder. So if you want to overridehue/light.py
with a custom version, you will also need to provide/copy overhue/__init__.py
.Related issue (if applicable): fixes home-assistant/architecture#141
Checklist:
tox
. Your PR cannot be merged unless tests passIf the code does not interact with devices: