1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 03:42:20 +01:00

Convert components to async-def syntax (#1823)

* Convert components to async-def syntax

* Remove stray @coroutine

* Manual part

* Convert complexer components code to async-def

* Manual cleanup

* More manual cleanup
This commit is contained in:
Otto Winter
2021-05-24 21:45:31 +02:00
committed by GitHub
parent 93d9d4b50a
commit a33bb32874
60 changed files with 592 additions and 633 deletions

View File

@@ -354,7 +354,7 @@ def safe_exp(obj: SafeExpType) -> Expression:
if inspect.isgenerator(obj):
raise ValueError(
"Object {} is a coroutine. Did you forget to await the expression with "
"'yield'?".format(obj)
"'await'?".format(obj)
)
raise ValueError("Object is not an expression", obj)
@@ -573,7 +573,7 @@ async def get_variable(id_: ID) -> "MockObj":
Wait for the given ID to be defined in the code generation and
return it as a MockObj.
This is a coroutine, you need to await it with a 'yield' expression!
This is a coroutine, you need to await it with a 'await' expression!
:param id_: The ID to retrieve
:return: The variable as a MockObj.
@@ -586,7 +586,7 @@ 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.
This is a coroutine, you need to await it with a 'yield' expression!
This is a coroutine, you need to await it with a 'await' expression!
:param id_: The ID to retrieve
:return: The variable as a MockObj.
@@ -603,7 +603,7 @@ async def process_lambda(
"""Process the given lambda value into a LambdaExpression.
This is a coroutine because lambdas can depend on other IDs,
you need to await it with 'yield'!
you need to await it with 'await'!
:param value: The lambda to process.
:param parameters: The parameters to pass to the Lambda, list of tuples