1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00

Bump python min to 3.9 (#3871)

This commit is contained in:
Jesse Hills
2022-10-05 20:09:27 +13:00
committed by GitHub
parent c3a8972550
commit d220d41182
25 changed files with 130 additions and 147 deletions

View File

@@ -8,14 +8,10 @@ from esphome.yaml_util import ESPHomeDataBase
from typing import (
Any,
Callable,
Generator,
List,
Optional,
Tuple,
Type,
Union,
Sequence,
)
from collections.abc import Generator, Sequence
from esphome.core import ( # noqa
CORE,
@@ -54,9 +50,9 @@ SafeExpType = Union[
int,
float,
TimePeriod,
Type[bool],
Type[int],
Type[float],
type[bool],
type[int],
type[float],
Sequence[Any],
]
@@ -150,7 +146,7 @@ class CallExpression(Expression):
class StructInitializer(Expression):
__slots__ = ("base", "args")
def __init__(self, base: Expression, *args: Tuple[str, Optional[SafeExpType]]):
def __init__(self, base: Expression, *args: tuple[str, Optional[SafeExpType]]):
self.base = base
# TODO: args is always a Tuple, is this check required?
if not isinstance(args, OrderedDict):
@@ -210,7 +206,7 @@ class ParameterListExpression(Expression):
__slots__ = ("parameters",)
def __init__(
self, *parameters: Union[ParameterExpression, Tuple[SafeExpType, str]]
self, *parameters: Union[ParameterExpression, tuple[SafeExpType, str]]
):
self.parameters = []
for parameter in parameters:
@@ -629,7 +625,7 @@ def add_define(name: str, value: SafeExpType = None):
CORE.add_define(Define(name, safe_exp(value)))
def add_platformio_option(key: str, value: Union[str, List[str]]):
def add_platformio_option(key: str, value: Union[str, list[str]]):
CORE.add_platformio_option(key, value)
@@ -646,7 +642,7 @@ async def get_variable(id_: ID) -> "MockObj":
return await CORE.get_variable(id_)
async def get_variable_with_full_id(id_: ID) -> Tuple[ID, "MockObj"]:
async def get_variable_with_full_id(id_: ID) -> tuple[ID, "MockObj"]:
"""
Wait for the given ID to be defined in the code generation and
return it as a MockObj.
@@ -661,7 +657,7 @@ async def get_variable_with_full_id(id_: ID) -> Tuple[ID, "MockObj"]:
async def process_lambda(
value: Lambda,
parameters: List[Tuple[SafeExpType, str]],
parameters: list[tuple[SafeExpType, str]],
capture: str = "=",
return_type: SafeExpType = None,
) -> Generator[LambdaExpression, None, None]:
@@ -715,7 +711,7 @@ def is_template(value):
async def templatable(
value: Any,
args: List[Tuple[SafeExpType, str]],
args: list[tuple[SafeExpType, str]],
output_type: Optional[SafeExpType],
to_exp: Any = None,
):
@@ -763,7 +759,7 @@ class MockObj(Expression):
attr = attr[1:]
return MockObj(f"{self.base}{self.op}{attr}", next_op)
def __call__(self, *args): # type: (SafeExpType) -> MockObj
def __call__(self, *args: SafeExpType) -> "MockObj":
call = CallExpression(self.base, *args)
return MockObj(call, self.op)