1
mirror of https://github.com/home-assistant/core synced 2024-10-01 05:30:36 +02:00

Allow None in add_suggested_values_to_schema (#85763)

This commit is contained in:
epenet 2023-01-16 11:36:21 +01:00 committed by GitHub
parent 11a81dc485
commit 13cfd60019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -457,7 +457,7 @@ class FlowHandler:
return self.context.get("show_advanced_options", False) return self.context.get("show_advanced_options", False)
def add_suggested_values_to_schema( def add_suggested_values_to_schema(
self, data_schema: vol.Schema, suggested_values: Mapping[str, Any] self, data_schema: vol.Schema, suggested_values: Mapping[str, Any] | None
) -> vol.Schema: ) -> vol.Schema:
"""Make a copy of the schema, populated with suggested values. """Make a copy of the schema, populated with suggested values.
@ -477,7 +477,11 @@ class FlowHandler:
continue continue
new_key = key new_key = key
if key in suggested_values and isinstance(key, vol.Marker): if (
suggested_values
and key in suggested_values
and isinstance(key, vol.Marker)
):
# Copy the marker to not modify the flow schema # Copy the marker to not modify the flow schema
new_key = copy.copy(key) new_key = copy.copy(key)
new_key.description = {"suggested_value": suggested_values[key]} new_key.description = {"suggested_value": suggested_values[key]}