11import sublime
2- from typing import Optional , Union , List , Dict , Tuple
32
3+ from typing import Callable , Generic , TypeVar , Optional , Union , List , Tuple , overload
44
5- class CommandInputHandler ():
5+
6+ InputType = TypeVar ('InputType' , bound = Union [str , int , float , list , dict , tuple , None ])
7+
8+
9+ class CommandInputHandler (Generic [InputType ]):
610 def name (self ) -> str : ...
711 def next_input (self , args : dict ) -> Optional [CommandInputHandler ]: ...
812 def placeholder (self ) -> str : ...
913 def initial_text (self ) -> str : ...
10- def preview (self , arg : dict ) -> Union [str , sublime .Html ]: ...
11- def validate (self , arg : dict ) -> bool : ...
14+ def preview (self , arg : InputType ) -> Union [str , sublime .Html ]: ...
15+ def validate (self , arg : InputType ) -> bool : ...
1216 def cancel (self ) -> None : ...
13- def confirm (self , arg : dict ) -> None : ...
17+
18+ @overload
19+ def confirm (self , arg : InputType ) -> None : ...
20+ @overload
21+ def confirm (self , arg : InputType , event : dict ) -> None : ...
1422
1523
16- class BackInputHandler (CommandInputHandler ):
24+ class BackInputHandler (CommandInputHandler [ None ] ):
1725 pass
1826
1927
20- class TextInputHandler (CommandInputHandler ):
28+ class TextInputHandler (CommandInputHandler [ str ] ):
2129 def description (self , text : str ) -> str : ...
2230
2331
24- class ListInputHandler (CommandInputHandler ):
25- def list_items (self ) -> list : ...
32+ ListItem = Union [str , Tuple [str , InputType ]]
33+
34+
35+ class ListInputHandler (CommandInputHandler [InputType ], Generic [InputType ]):
36+ def list_items (self ) -> Union [List [ListItem ], Tuple [List [ListItem ], int ]]: ...
2637 def description (self , v : object , text : str ) -> str : ...
2738
2839
29- class Command () :
40+ class Command :
3041 def is_enabled (self ) -> bool : ...
3142 def is_visible (self ) -> bool : ...
3243 def is_checked (self ) -> bool : ...
@@ -36,23 +47,25 @@ class Command():
3647
3748
3849class ApplicationCommand (Command ):
39- def run ( self ) -> None : ...
50+ run : Callable [ ..., None ]
4051
4152
4253class WindowCommand (Command ):
4354 window : sublime .Window
4455
45- def run ( self ) -> None : ...
56+ run : Callable [ ..., None ]
4657
4758
4859class TextCommand (Command ):
4960 view : sublime .View
5061
51- def run ( self , edit : sublime . Edit ) -> None : ...
62+ run : Callable [..., None ]
5263 def want_event (self ) -> bool : ...
5364
5465
55- class EventListener ():
66+ Completion = Union [str , Tuple [str , str ], List [str ]]
67+
68+ class EventListener :
5669 def on_new (self , view : sublime .View ) -> None : ...
5770 def on_new_async (self , view : sublime .View ) -> None : ...
5871 def on_clone (self , view : sublime .View ) -> None : ...
@@ -74,15 +87,15 @@ class EventListener():
7487 def on_deactivated (self , view : sublime .View ) -> None : ...
7588 def on_deactivated_async (self , view : sublime .View ) -> None : ...
7689 def on_hover (self , view : sublime .View , point : int , hover_zone : int ) -> None : ...
77- def on_query_context (self , view : sublime .View , key : str , operator : int , operand : str , match_all : bool ) -> Optional [None ]: ...
78- def on_query_completions (self , view : sublime .View , prefix : str , locations : List [int ]) -> Union [None , list , tuple ]: ...
79- def on_text_command (self , view : sublime .View , command_name : str , args : dict ) -> Tuple [str , dict ]: ...
90+ def on_query_context (self , view : sublime .View , key : str , operator : int , operand : str , match_all : bool ) -> Optional [bool ]: ...
91+ def on_query_completions (self , view : sublime .View , prefix : str , locations : List [int ]) -> Union [None , List [ Completion ], Tuple [ List [ Completion ], int ] ]: ...
92+ def on_text_command (self , view : sublime .View , command_name : str , args : dict ) -> Optional [ Tuple [str , dict ] ]: ...
8093 def on_post_text_command (self , view : sublime .View , command_name : str , args : dict ) -> None : ...
81- def on_window_command (self , view : sublime .Window , command_name : str , args : dict ) -> Tuple [str , dict ]: ...
94+ def on_window_command (self , view : sublime .Window , command_name : str , args : dict ) -> Optional [ Tuple [str , dict ] ]: ...
8295 def on_post_window_command (self , view : sublime .Window , command_name : str , args : dict ) -> None : ...
8396
8497
85- class ViewEventListener () :
98+ class ViewEventListener :
8699 view : sublime .View
87100
88101 @classmethod
@@ -108,7 +121,7 @@ class ViewEventListener():
108121 def on_deactivated_modified (self ) -> None : ...
109122 def on_deactivated_modified_async (self ) -> None : ...
110123 def on_hover (self , point : int , hover_zone : int ) -> None : ...
111- def on_query_context (self , key : str , operator : int , operand : str , match_all : bool ) -> Optional [None ]: ...
112- def on_query_completions (self , prefix : str , locations : List [int ]) -> Union [None , list , tuple ]: ...
113- def on_text_command (self , command_name : str , args : dict ) -> Tuple [str , dict ]: ...
124+ def on_query_context (self , key : str , operator : int , operand : str , match_all : bool ) -> Optional [bool ]: ...
125+ def on_query_completions (self , prefix : str , locations : List [int ]) -> Union [None , List [ Completion ], Tuple [ List [ Completion ], int ] ]: ...
126+ def on_text_command (self , command_name : str , args : dict ) -> Optional [ Tuple [str , dict ] ]: ...
114127 def on_post_text_command (self , command_name : str , args : dict ) -> None : ...
0 commit comments