11from __future__ import annotations
22
33from abc import ABC
4- from typing import Annotated , Any , Generic , Literal , NamedTuple , Optional , Union
4+ from typing import Annotated , Generic , Literal , NamedTuple , Optional , Union
55
6- from pydantic import Field
6+ from pydantic import Field , JsonValue
77from typing_extensions import TypedDict , TypeVar
88
99from streamdeck .models .events .base import ConfiguredBaseModel
@@ -28,8 +28,11 @@ class DeviceSpecificEventMixin:
2828## Payload models and metadata used by multiple event models.
2929
3030
31- PluginDefinedData = dict [str , Any ]
32- """Data of arbitrary structure that is defined in and relevant to the plugin."""
31+ PluginDefinedData = dict [str , JsonValue ]
32+ """Data of arbitrary structure that is defined in and relevant to the plugin.
33+
34+ The root of the data structure will always be a dict of string keys, while the values can be any JSON-compatible type.
35+ """
3336
3437
3538EncoderControllerType = Literal ["Encoder" ]
@@ -116,10 +119,14 @@ class MultiActionPayloadMixin:
116119 """Indicates that this event is part of a multi-action."""
117120
118121
122+ # These need to be covariant, as the Mixin classes are never meant to be instantiated themselves, only inherited from.
123+ SingleActionPayload_co = TypeVar ("SingleActionPayload_co" , bound = SingleActionPayloadMixin , covariant = True )
124+ MultiActionPayload_co = TypeVar ("MultiActionPayload_co" , bound = MultiActionPayloadMixin , covariant = True )
125+
119126CardinalityDiscriminated = Annotated [
120127 Union [ # noqa: UP007
121- TypeVar ( "S" , bound = SingleActionPayloadMixin ) ,
122- TypeVar ( "M" , bound = MultiActionPayloadMixin ) ,
128+ SingleActionPayload_co ,
129+ MultiActionPayload_co ,
123130 ],
124131 Field (discriminator = "is_in_multi_action" ),
125132]
0 commit comments