mirror of
https://github.com/esphome/esphome.git
synced 2025-09-07 05:42:20 +01:00
update minimal python version to 3.10 (#8850)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from collections.abc import Callable
|
||||
from contextlib import AbstractContextManager
|
||||
from dataclasses import dataclass
|
||||
import importlib
|
||||
@@ -8,7 +9,7 @@ import logging
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, Optional
|
||||
from typing import Any
|
||||
|
||||
from esphome.const import SOURCE_FILE_EXTENSIONS
|
||||
from esphome.core import CORE
|
||||
@@ -57,7 +58,7 @@ class ComponentManifest:
|
||||
return getattr(self.module, "IS_TARGET_PLATFORM", False)
|
||||
|
||||
@property
|
||||
def config_schema(self) -> Optional[Any]:
|
||||
def config_schema(self) -> Any | None:
|
||||
return getattr(self.module, "CONFIG_SCHEMA", None)
|
||||
|
||||
@property
|
||||
@@ -69,7 +70,7 @@ class ComponentManifest:
|
||||
return getattr(self.module, "MULTI_CONF_NO_DEFAULT", False)
|
||||
|
||||
@property
|
||||
def to_code(self) -> Optional[Callable[[Any], None]]:
|
||||
def to_code(self) -> Callable[[Any], None] | None:
|
||||
return getattr(self.module, "to_code", None)
|
||||
|
||||
@property
|
||||
@@ -96,7 +97,7 @@ class ComponentManifest:
|
||||
return getattr(self.module, "INSTANCE_TYPE", None)
|
||||
|
||||
@property
|
||||
def final_validate_schema(self) -> Optional[Callable[[ConfigType], None]]:
|
||||
def final_validate_schema(self) -> Callable[[ConfigType], None] | None:
|
||||
"""Components can declare a `FINAL_VALIDATE_SCHEMA` cv.Schema that gets called
|
||||
after the main validation. In that function checks across components can be made.
|
||||
|
||||
@@ -129,7 +130,7 @@ class ComponentManifest:
|
||||
|
||||
class ComponentMetaFinder(importlib.abc.MetaPathFinder):
|
||||
def __init__(
|
||||
self, components_path: Path, allowed_components: Optional[list[str]] = None
|
||||
self, components_path: Path, allowed_components: list[str] | None = None
|
||||
) -> None:
|
||||
self._allowed_components = allowed_components
|
||||
self._finders = []
|
||||
@@ -140,7 +141,7 @@ class ComponentMetaFinder(importlib.abc.MetaPathFinder):
|
||||
continue
|
||||
self._finders.append(finder)
|
||||
|
||||
def find_spec(self, fullname: str, path: Optional[list[str]], target=None):
|
||||
def find_spec(self, fullname: str, path: list[str] | None, target=None):
|
||||
if not fullname.startswith("esphome.components."):
|
||||
return None
|
||||
parts = fullname.split(".")
|
||||
@@ -167,7 +168,7 @@ def clear_component_meta_finders():
|
||||
|
||||
|
||||
def install_meta_finder(
|
||||
components_path: Path, allowed_components: Optional[list[str]] = None
|
||||
components_path: Path, allowed_components: list[str] | None = None
|
||||
):
|
||||
sys.meta_path.insert(0, ComponentMetaFinder(components_path, allowed_components))
|
||||
|
||||
|
Reference in New Issue
Block a user