mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 11:26:39 +00:00
[core] Defer stdlib imports out of the upload and logs fast path (#18105)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import binascii
|
||||
from datetime import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from esphome import const
|
||||
from esphome.const import (
|
||||
@@ -24,6 +24,9 @@ from esphome.core import CORE, EsphomeError, Version
|
||||
from esphome.helpers import write_file_if_changed
|
||||
from esphome.types import CoreType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from datetime import datetime
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -372,6 +375,10 @@ class EsphomeStorageJSON:
|
||||
|
||||
@property
|
||||
def last_update_check(self) -> datetime | None:
|
||||
# Deferred: this module is on the upload/logs fast path; only the
|
||||
# dashboard's update check touches these accessors.
|
||||
from datetime import datetime
|
||||
|
||||
try:
|
||||
# Stored format is naive ISO without %z; preserved for backward compat.
|
||||
return datetime.strptime( # noqa: DTZ007
|
||||
|
||||
Reference in New Issue
Block a user