1- from typing import TYPE_CHECKING , Literal , TypedDict
1+ from typing import TYPE_CHECKING , Union , Literal , Optional , TypedDict
22from contextlib import contextmanager
33from collections import defaultdict
44from contextvars import ContextVar
@@ -58,7 +58,7 @@ def __init__(
5858 self ,
5959 app : "ProcessMixin" ,
6060 * args ,
61- matchers : dict [int , list [type ["Matcher" ]]] | None ,
61+ matchers : Optional [ dict [int , list [type ["Matcher" ]]]] ,
6262 ** kwargs ,
6363 ):
6464 super ().__init__ (app , * args , ** kwargs )
@@ -77,19 +77,21 @@ def receive_event(self, bot: "Bot", event: "Event") -> ReceiveEvent:
7777 self .event_list .append ((receive_event , EventTest (checks = [], actions = [])))
7878 return receive_event
7979
80- def should_pass_rule (self , matcher : type ["Matcher" ] | None = None ) -> RulePass :
80+ def should_pass_rule (self , matcher : Optional [ type ["Matcher" ]] = None ) -> RulePass :
8181 rule = RulePass (matcher = matcher )
8282 self .currect_event_test ["checks" ].append (rule )
8383 return rule
8484
8585 def should_not_pass_rule (
86- self , matcher : type ["Matcher" ] | None = None
86+ self , matcher : Optional [ type ["Matcher" ]] = None
8787 ) -> RuleNotPass :
8888 rule = RuleNotPass (matcher = matcher )
8989 self .currect_event_test ["checks" ].append (rule )
9090 return rule
9191
92- def should_ignore_rule (self , matcher : type ["Matcher" ] | None = None ) -> IgnoreRule :
92+ def should_ignore_rule (
93+ self , matcher : Optional [type ["Matcher" ]] = None
94+ ) -> IgnoreRule :
9395 rule = IgnoreRule (matcher = matcher )
9496 self .currect_event_test ["checks" ].append (rule )
9597 return rule
@@ -123,21 +125,21 @@ def got_check_rule(self, matcher: type["Matcher"], result: bool) -> bool:
123125 return result
124126
125127 def should_pass_permission (
126- self , matcher : type ["Matcher" ] | None = None
128+ self , matcher : Optional [ type ["Matcher" ]] = None
127129 ) -> PermissionPass :
128130 permission = PermissionPass (matcher = matcher )
129131 self .currect_event_test ["checks" ].append (permission )
130132 return permission
131133
132134 def should_not_pass_permission (
133- self , matcher : type ["Matcher" ] | None = None
135+ self , matcher : Optional [ type ["Matcher" ]] = None
134136 ) -> PermissionNotPass :
135137 permission = PermissionNotPass (matcher = matcher )
136138 self .currect_event_test ["checks" ].append (permission )
137139 return permission
138140
139141 def should_ignore_permission (
140- self , matcher : type ["Matcher" ] | None = None
142+ self , matcher : Optional [ type ["Matcher" ]] = None
141143 ) -> IgnorePermission :
142144 permission = IgnorePermission (matcher = matcher )
143145 self .currect_event_test ["checks" ].append (permission )
@@ -173,7 +175,7 @@ def got_check_permission(self, matcher: type["Matcher"], result: bool) -> bool:
173175 break
174176 return result
175177
176- def should_paused (self , matcher : type ["Matcher" ] | None = None ) -> Paused :
178+ def should_paused (self , matcher : Optional [ type ["Matcher" ]] = None ) -> Paused :
177179 if any (
178180 action .matcher is matcher for action in self .currect_event_test ["actions" ]
179181 ):
@@ -182,7 +184,7 @@ def should_paused(self, matcher: type["Matcher"] | None = None) -> Paused:
182184 self .currect_event_test ["actions" ].append (paused )
183185 return paused
184186
185- def should_rejected (self , matcher : type ["Matcher" ] | None = None ) -> Rejected :
187+ def should_rejected (self , matcher : Optional [ type ["Matcher" ]] = None ) -> Rejected :
186188 if any (
187189 action .matcher is matcher for action in self .currect_event_test ["actions" ]
188190 ):
@@ -191,7 +193,7 @@ def should_rejected(self, matcher: type["Matcher"] | None = None) -> Rejected:
191193 self .currect_event_test ["actions" ].append (rejected )
192194 return rejected
193195
194- def should_finished (self , matcher : type ["Matcher" ] | None = None ) -> Finished :
196+ def should_finished (self , matcher : Optional [ type ["Matcher" ]] = None ) -> Finished :
195197 if any (
196198 action .matcher is matcher for action in self .currect_event_test ["actions" ]
197199 ):
@@ -285,13 +287,15 @@ async def run(self):
285287class ProcessMixin (BaseApp ):
286288 def test_matcher (
287289 self ,
288- m : None
289- | type ["Matcher" ]
290- | list [type ["Matcher" ]]
291- | dict [int , list [type ["Matcher" ]]] = None ,
290+ m : Union [
291+ None ,
292+ type ["Matcher" ],
293+ list [type ["Matcher" ]],
294+ dict [int , list [type ["Matcher" ]]],
295+ ] = None ,
292296 / ,
293297 ) -> MatcherContext :
294- matchers : dict [int , list [type ["Matcher" ]]] | None
298+ matchers : Optional [ dict [int , list [type ["Matcher" ]]]]
295299 if m is None :
296300 matchers = None
297301 elif isinstance (m , list ):
0 commit comments