@@ -283,9 +283,7 @@ def manifest_from_legacy_module(domain: str, module: ModuleType) -> Manifest:
283283 }
284284
285285
286- async def _async_get_custom_components (
287- hass : HomeAssistant ,
288- ) -> dict [str , Integration ]:
286+ def _get_custom_components (hass : HomeAssistant ) -> dict [str , Integration ]:
289287 """Return list of custom integrations."""
290288 if hass .config .recovery_mode or hass .config .safe_mode :
291289 return {}
@@ -295,21 +293,14 @@ async def _async_get_custom_components(
295293 except ImportError :
296294 return {}
297295
298- def get_sub_directories (paths : list [str ]) -> list [pathlib .Path ]:
299- """Return all sub directories in a set of paths."""
300- return [
301- entry
302- for path in paths
303- for entry in pathlib .Path (path ).iterdir ()
304- if entry .is_dir ()
305- ]
306-
307- dirs = await hass .async_add_executor_job (
308- get_sub_directories , custom_components .__path__
309- )
296+ dirs = [
297+ entry
298+ for path in custom_components .__path__
299+ for entry in pathlib .Path (path ).iterdir ()
300+ if entry .is_dir ()
301+ ]
310302
311- integrations = await hass .async_add_executor_job (
312- _resolve_integrations_from_root ,
303+ integrations = _resolve_integrations_from_root (
313304 hass ,
314305 custom_components ,
315306 [comp .name for comp in dirs ],
@@ -330,7 +321,7 @@ async def async_get_custom_components(
330321 if comps_or_future is None :
331322 future = hass .data [DATA_CUSTOM_COMPONENTS ] = hass .loop .create_future ()
332323
333- comps = await _async_get_custom_components ( hass )
324+ comps = await hass . async_add_executor_job ( _get_custom_components , hass )
334325
335326 hass .data [DATA_CUSTOM_COMPONENTS ] = comps
336327 future .set_result (comps )
0 commit comments