Schemable is great as parameter type. However, without a dedicated type annotation mypy will also use it as argument type for Schema.schema and Marker.schema which just creates unhelpful errors when used
error: Unsupported right operand type for in ("Schema | Object | Mapping[Any, Any] |
list[Any] | tuple[Any, ...] | <12 more items> | None") [operator]
error: Item "Schema" of "Schema | Object | Mapping[Any, Any] | list[Any] | tuple[Any, ...] |
<12 more items> | None" has no attribute "items" [union-attr]
Typing it as Any will "disable" type checking when using the schema attribute, while still providing the type safety for the parameter type.
An alternative would have been #520. However that comes with its own set of issues as now all Schemas are generic and need additional type annotations.
Schemable
is great as parameter type. However, without a dedicated type annotation mypy will also use it as argument type forSchema.schema
andMarker.schema
which just creates unhelpful errors when usedTyping it as
Any
will "disable" type checking when using theschema
attribute, while still providing the type safety for the parameter type.An alternative would have been #520. However that comes with its own set of issues as now all
Schemas
are generic and need additional type annotations.Refs https://github.com/home-assistant/core/pull/120268