mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Typing hint and doc fixes (#6729)
This commit is contained in:
parent
13e3920c13
commit
dd81c83686
1 changed files with 7 additions and 7 deletions
|
@ -2,7 +2,7 @@ import abc
|
||||||
import inspect
|
import inspect
|
||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
from collections.abc import Generator, Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Any, Callable, Optional, Union
|
from typing import Any, Callable, Optional, Union
|
||||||
|
|
||||||
from esphome.core import (
|
from esphome.core import (
|
||||||
|
@ -477,6 +477,7 @@ def variable(
|
||||||
:param rhs: The expression to place on the right hand side of the assignment.
|
:param rhs: The expression to place on the right hand side of the assignment.
|
||||||
:param type_: Manually define a type for the variable, only use this when it's not possible
|
:param type_: Manually define a type for the variable, only use this when it's not possible
|
||||||
to do so during config validation phase (for example because of template arguments).
|
to do so during config validation phase (for example because of template arguments).
|
||||||
|
:param register: If true register the variable with the core
|
||||||
|
|
||||||
:return: The new variable as a MockObj.
|
:return: The new variable as a MockObj.
|
||||||
"""
|
"""
|
||||||
|
@ -492,9 +493,7 @@ def variable(
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
def with_local_variable(
|
def with_local_variable(id_: ID, rhs: SafeExpType, callback: Callable, *args) -> None:
|
||||||
id_: ID, rhs: SafeExpType, callback: Callable[["MockObj"], None], *args
|
|
||||||
) -> None:
|
|
||||||
"""Declare a new variable, not pointer type, in the code generation, within a scoped block
|
"""Declare a new variable, not pointer type, in the code generation, within a scoped block
|
||||||
The variable is only usable within the callback
|
The variable is only usable within the callback
|
||||||
The callback cannot be async.
|
The callback cannot be async.
|
||||||
|
@ -599,6 +598,7 @@ def add_library(name: str, version: Optional[str], repository: Optional[str] = N
|
||||||
|
|
||||||
:param name: The name of the library (for example 'AsyncTCP')
|
:param name: The name of the library (for example 'AsyncTCP')
|
||||||
:param version: The version of the library, may be None.
|
:param version: The version of the library, may be None.
|
||||||
|
:param repository: The repository for the library
|
||||||
"""
|
"""
|
||||||
CORE.add_library(Library(name, version, repository))
|
CORE.add_library(Library(name, version, repository))
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ async def process_lambda(
|
||||||
parameters: list[tuple[SafeExpType, str]],
|
parameters: list[tuple[SafeExpType, str]],
|
||||||
capture: str = "=",
|
capture: str = "=",
|
||||||
return_type: SafeExpType = None,
|
return_type: SafeExpType = None,
|
||||||
) -> Generator[LambdaExpression, None, None]:
|
) -> Union[LambdaExpression, None]:
|
||||||
"""Process the given lambda value into a LambdaExpression.
|
"""Process the given lambda value into a LambdaExpression.
|
||||||
|
|
||||||
This is a coroutine because lambdas can depend on other IDs,
|
This is a coroutine because lambdas can depend on other IDs,
|
||||||
|
@ -673,7 +673,7 @@ async def process_lambda(
|
||||||
)
|
)
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
return
|
return None
|
||||||
parts = value.parts[:]
|
parts = value.parts[:]
|
||||||
for i, id in enumerate(value.requires_ids):
|
for i, id in enumerate(value.requires_ids):
|
||||||
full_id, var = await get_variable_with_full_id(id)
|
full_id, var = await get_variable_with_full_id(id)
|
||||||
|
@ -712,7 +712,7 @@ async def templatable(
|
||||||
value: Any,
|
value: Any,
|
||||||
args: list[tuple[SafeExpType, str]],
|
args: list[tuple[SafeExpType, str]],
|
||||||
output_type: Optional[SafeExpType],
|
output_type: Optional[SafeExpType],
|
||||||
to_exp: Any = None,
|
to_exp: Union[Callable, dict] = None,
|
||||||
):
|
):
|
||||||
"""Generate code for a templatable config option.
|
"""Generate code for a templatable config option.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue