Schemable is great as a catch all case. However, the Union prevents further uses especially of the schema attribute.
E.g.
schema = vol.Schema({"key": str})
schema.schema.items() # should access the dict items used to create the schema
This PR changes the schema attribute type to a TypeVar. This allows for either implicit or explicit specialization by the user. It would fallback to typing.Any if type checkers can't infer the specialized type.
That's still better than the current situation as that just always emits an error.
error: Item "type" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] |
<12 more items> | None" has no attribute "__iter__" (not iterable) [union-attr]
Schemable
is great as a catch all case. However, the Union prevents further uses especially of theschema
attribute. E.g.This PR changes the
schema
attribute type to aTypeVar
. This allows for either implicit or explicit specialization by the user. It would fallback totyping.Any
if type checkers can't infer the specialized type.That's still better than the current situation as that just always emits an error.
Refs https://github.com/home-assistant/core/pull/120268