mirror of
https://github.com/esphome/esphome.git
synced 2025-09-27 15:42:22 +01:00
[core] Add typing to some core files (#10843)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import abc
|
||||
from collections.abc import Callable, Sequence
|
||||
from collections.abc import Callable
|
||||
import inspect
|
||||
import math
|
||||
import re
|
||||
@@ -13,7 +13,6 @@ from esphome.core import (
|
||||
HexInt,
|
||||
Lambda,
|
||||
Library,
|
||||
TimePeriod,
|
||||
TimePeriodMicroseconds,
|
||||
TimePeriodMilliseconds,
|
||||
TimePeriodMinutes,
|
||||
@@ -21,35 +20,11 @@ from esphome.core import (
|
||||
TimePeriodSeconds,
|
||||
)
|
||||
from esphome.helpers import cpp_string_escape, indent_all_but_first_and_last
|
||||
from esphome.types import Expression, SafeExpType, TemplateArgsType
|
||||
from esphome.util import OrderedDict
|
||||
from esphome.yaml_util import ESPHomeDataBase
|
||||
|
||||
|
||||
class Expression(abc.ABC):
|
||||
__slots__ = ()
|
||||
|
||||
@abc.abstractmethod
|
||||
def __str__(self):
|
||||
"""
|
||||
Convert expression into C++ code
|
||||
"""
|
||||
|
||||
|
||||
SafeExpType = (
|
||||
Expression
|
||||
| bool
|
||||
| str
|
||||
| str
|
||||
| int
|
||||
| float
|
||||
| TimePeriod
|
||||
| type[bool]
|
||||
| type[int]
|
||||
| type[float]
|
||||
| Sequence[Any]
|
||||
)
|
||||
|
||||
|
||||
class RawExpression(Expression):
|
||||
__slots__ = ("text",)
|
||||
|
||||
@@ -575,7 +550,7 @@ def Pvariable(id_: ID, rhs: SafeExpType, type_: "MockObj" = None) -> "MockObj":
|
||||
return obj
|
||||
|
||||
|
||||
def new_Pvariable(id_: ID, *args: SafeExpType) -> Pvariable:
|
||||
def new_Pvariable(id_: ID, *args: SafeExpType) -> "MockObj":
|
||||
"""Declare a new pointer variable in the code generation by calling it's constructor
|
||||
with the given arguments.
|
||||
|
||||
@@ -681,7 +656,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: TemplateArgsType,
|
||||
capture: str = "=",
|
||||
return_type: SafeExpType = None,
|
||||
) -> LambdaExpression | None:
|
||||
|
Reference in New Issue
Block a user