mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 16:37:52 +01:00
Typing hint and doc fixes (#6729)
This commit is contained in:
parent
13e3920c13
commit
dd81c83686
@ -2,7 +2,7 @@ import abc
|
||||
import inspect
|
||||
import math
|
||||
import re
|
||||
from collections.abc import Generator, Sequence
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, Callable, Optional, Union
|
||||
|
||||
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 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).
|
||||
:param register: If true register the variable with the core
|
||||
|
||||
:return: The new variable as a MockObj.
|
||||
"""
|
||||
@ -492,9 +493,7 @@ def variable(
|
||||
return obj
|
||||
|
||||
|
||||
def with_local_variable(
|
||||
id_: ID, rhs: SafeExpType, callback: Callable[["MockObj"], None], *args
|
||||
) -> None:
|
||||
def with_local_variable(id_: ID, rhs: SafeExpType, callback: Callable, *args) -> None:
|
||||
"""Declare a new variable, not pointer type, in the code generation, within a scoped block
|
||||
The variable is only usable within the callback
|
||||
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 version: The version of the library, may be None.
|
||||
:param repository: The repository for the library
|
||||
"""
|
||||
CORE.add_library(Library(name, version, repository))
|
||||
|
||||
@ -654,7 +654,7 @@ async def process_lambda(
|
||||
parameters: list[tuple[SafeExpType, str]],
|
||||
capture: str = "=",
|
||||
return_type: SafeExpType = None,
|
||||
) -> Generator[LambdaExpression, None, None]:
|
||||
) -> Union[LambdaExpression, None]:
|
||||
"""Process the given lambda value into a LambdaExpression.
|
||||
|
||||
This is a coroutine because lambdas can depend on other IDs,
|
||||
@ -673,7 +673,7 @@ async def process_lambda(
|
||||
)
|
||||
|
||||
if value is None:
|
||||
return
|
||||
return None
|
||||
parts = value.parts[:]
|
||||
for i, id in enumerate(value.requires_ids):
|
||||
full_id, var = await get_variable_with_full_id(id)
|
||||
@ -712,7 +712,7 @@ async def templatable(
|
||||
value: Any,
|
||||
args: list[tuple[SafeExpType, str]],
|
||||
output_type: Optional[SafeExpType],
|
||||
to_exp: Any = None,
|
||||
to_exp: Union[Callable, dict] = None,
|
||||
):
|
||||
"""Generate code for a templatable config option.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user