11import json
2- import typing
32import logging
4- from typing import Any , Dict , Iterator , Optional
3+ import typing
54from collections import defaultdict
6- from collections .abc import MutableMapping
5+ from collections .abc import Iterator , MutableMapping
6+ from typing import Any
77
88from . import exceptions
99
@@ -26,20 +26,16 @@ class Action(MutableMapping):
2626 def __init__ (
2727 self ,
2828 raw_action : typing .MutableMapping ,
29- verification_token : Optional [ str ] = None ,
30- team_id : Optional [ str ] = None ,
29+ verification_token : str | None = None ,
30+ team_id : str | None = None ,
3131 ) -> None :
3232 self .action = raw_action
3333
3434 if verification_token and self .action ["token" ] != verification_token :
35- raise exceptions .FailedVerification (
36- self .action ["token" ], self .action ["team" ]["id" ]
37- )
35+ raise exceptions .FailedVerification (self .action ["token" ], self .action ["team" ]["id" ])
3836
3937 if team_id and self .action ["team" ]["id" ] != team_id :
40- raise exceptions .FailedVerification (
41- self .action ["token" ], self .action ["team" ]["id" ]
42- )
38+ raise exceptions .FailedVerification (self .action ["token" ], self .action ["team" ]["id" ])
4339
4440 def __getitem__ (self , item ):
4541 return self .action [item ]
@@ -63,8 +59,8 @@ def __repr__(self):
6359 def from_http (
6460 cls ,
6561 payload : typing .MutableMapping ,
66- verification_token : Optional [ str ] = None ,
67- team_id : Optional [ str ] = None ,
62+ verification_token : str | None = None ,
63+ team_id : str | None = None ,
6864 ) -> "Action" :
6965 action = json .loads (payload ["payload" ])
7066 return cls (action , verification_token = verification_token , team_id = team_id )
@@ -77,7 +73,7 @@ class Router:
7773 """
7874
7975 def __init__ (self ):
80- self ._routes : Dict [str , Dict ] = defaultdict (dict )
76+ self ._routes : dict [str , dict ] = defaultdict (dict )
8177
8278 def register (self , callback_id : str , handler : Any , name : str = "*" ) -> None :
8379 """
@@ -98,9 +94,7 @@ def register(self, callback_id: str, handler: Any, name: str = "*") -> None:
9894
9995 self ._routes [callback_id ][name ].append (handler )
10096
101- def register_interactive_message (
102- self , callback_id : str , handler : Any , name : str = "*"
103- ) -> None :
97+ def register_interactive_message (self , callback_id : str , handler : Any , name : str = "*" ) -> None :
10498 """
10599 Register a new handler for a specific :class:`slack.actions.Action` `callback_id`.
106100 Optional routing based on the action name too.
@@ -118,9 +112,7 @@ def register_interactive_message(
118112 """
119113 self .register (callback_id , handler , name )
120114
121- def register_block_action (
122- self , block_id : str , handler : Any , action_id : str = "*"
123- ) -> None :
115+ def register_block_action (self , block_id : str , handler : Any , action_id : str = "*" ) -> None :
124116 """
125117 Register a new handler for a block-based :class:`slack.actions.Action`.
126118 Internally uses the base `register` method for actual registration.
@@ -158,9 +150,7 @@ def dispatch(self, action: Action) -> Any:
158150 handler
159151 """
160152 if "callback_id" in action :
161- LOG .debug (
162- "Dispatching action %s, %s" , action ["type" ], action ["callback_id" ]
163- )
153+ LOG .debug ("Dispatching action %s, %s" , action ["type" ], action ["callback_id" ])
164154 else :
165155 LOG .debug (
166156 "Dispatching action %s, %s" ,
0 commit comments