Files
esphome/tests/unit_tests
J. Nick Koston fa055b9e49 [core] Lazy-load zeroconf/writer/yaml_util in __main__
Every \`esphome\` CLI invocation pays the cost of whatever \`esphome/__main__.py\`
imports at module scope before the requested command even runs. This
moves three heavy imports into the functions that actually use them:

- \`esphome.zeroconf\` (discover_mdns_devices): only needed for the
  name_add_mac_suffix OTA discovery path.
- \`esphome.writer\`: only needed by compile/clean paths.
- \`esphome.yaml_util\`: only needed by codegen, config dump, and rename.

Local measurement drops from ~75ms to ~47ms (-37%) for a cold
\`python -c 'import esphome.__main__'\`. The zeroconf chain alone accounts
for most of the gain — the case that motivated the CI budget check.

Also adds a module-level note explaining the intent so future PRs don't
innocently promote these back to the top.

Retargets four test patches from \`esphome.__main__.discover_mdns_devices\`
to \`esphome.zeroconf.discover_mdns_devices\` now that the symbol is only
bound inside the function that calls it.
2026-04-23 14:47:10 -05:00
..
2025-09-19 12:59:48 +00:00
2022-10-05 20:09:27 +13:00
2025-09-19 12:59:48 +00:00