Avoid keeping config dir in path (#107760)

This commit is contained in:
Joakim Plate 2024-01-16 13:38:47 +01:00 committed by GitHub
parent 7fe6fc987b
commit 523352c97e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View file

@ -1177,8 +1177,12 @@ def _async_mount_config_dir(hass: HomeAssistant) -> None:
Async friendly but not a coroutine.
"""
if hass.config.config_dir not in sys.path:
sys.path.insert(0, hass.config.config_dir)
sys.path.insert(0, hass.config.config_dir)
with suppress(ImportError):
import custom_components # pylint: disable=import-outside-toplevel # noqa: F401
sys.path.remove(hass.config.config_dir)
sys.path_importer_cache.pop(hass.config.config_dir, None)
def _lookup_path(hass: HomeAssistant) -> list[str]: