99from __future__ import annotations
1010
1111from collections .abc import Callable
12- from typing import Any , TypedDict
12+ from typing import Any , Optional , TypedDict , Union
1313
1414from typing_extensions import TypeAlias
1515from yarl import URL
@@ -57,7 +57,7 @@ class Message(TypedDict):
5757 """
5858
5959
60- MessageProducerFull : TypeAlias = Callable [[str , dict [str , Any ] | None ], Message ]
60+ MessageProducerFull : TypeAlias = Callable [[str , Optional [ dict [str , Any ]] ], Message ]
6161"""
6262Full message producer signature.
6363
@@ -69,7 +69,7 @@ class Message(TypedDict):
6969The function must return a `bytes` object.
7070"""
7171
72- MessageProducerNoName : TypeAlias = Callable [[dict [str , Any ] | None ], Message ]
72+ MessageProducerNoName : TypeAlias = Callable [[Optional [ dict [str , Any ]] ], Message ]
7373"""
7474Message producer signature without the name.
7575
@@ -83,7 +83,7 @@ class Message(TypedDict):
8383functions.
8484"""
8585
86- StateHandlerFull : TypeAlias = Callable [[str , str , dict [str , Any ] | None ], None ]
86+ StateHandlerFull : TypeAlias = Callable [[str , str , Optional [ dict [str , Any ]] ], None ]
8787"""
8888Full state handler signature.
8989
@@ -93,7 +93,7 @@ class Message(TypedDict):
93932. The action (either `setup` or `teardown`), as a string.
94943. A dictionary of parameters, or `None` if no parameters are provided.
9595"""
96- StateHandlerNoAction : TypeAlias = Callable [[str , dict [str , Any ] | None ], None ]
96+ StateHandlerNoAction : TypeAlias = Callable [[str , Optional [ dict [str , Any ]] ], None ]
9797"""
9898State handler signature without the action.
9999
@@ -102,7 +102,7 @@ class Message(TypedDict):
1021021. The state name, as a string.
1031032. A dictionary of parameters, or `None` if no parameters are provided.
104104"""
105- StateHandlerNoState : TypeAlias = Callable [[str , dict [str , Any ] | None ], None ]
105+ StateHandlerNoState : TypeAlias = Callable [[str , Optional [ dict [str , Any ]] ], None ]
106106"""
107107State handler signature without the state.
108108
@@ -114,7 +114,7 @@ class Message(TypedDict):
114114This function must be provided as part of a dictionary mapping state names to
115115functions.
116116"""
117- StateHandlerNoActionNoState : TypeAlias = Callable [[dict [str , Any ] | None ], None ]
117+ StateHandlerNoActionNoState : TypeAlias = Callable [[Optional [ dict [str , Any ]] ], None ]
118118"""
119119State handler signature without the state or action.
120120
@@ -125,7 +125,7 @@ class Message(TypedDict):
125125This function must be provided as part of a dictionary mapping state names to
126126functions.
127127"""
128- StateHandlerUrl : TypeAlias = str | URL
128+ StateHandlerUrl : TypeAlias = Union [ str , URL ]
129129"""
130130State handler URL signature.
131131
0 commit comments