Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions stubs/sublime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def active_window() -> Window: ...
def windows() -> List[Window]: ...
def get_macro() -> list: ...

class Window(object):
class Window:
def __init__(self, id: int): ...
def __eq__(self, other: Any) -> bool: ...
def __bool__(self) -> bool: ...
Expand Down Expand Up @@ -186,10 +186,10 @@ class Window(object):
def extract_variables(self) -> dict: ...
def status_message(self, msg: str) -> None: ...

class Edit(object):
class Edit:
def __init__(self, token: int) -> None: ...

class Region(object):
class Region:
__slots__ = ['a', 'b', 'xpos']

a = 0 # type: int
Expand All @@ -211,7 +211,7 @@ class Region(object):
def intersection(self, rhs: Region) -> Region: ...
def intersects(self, rhs: Region) -> bool: ...

class Selection(object):
class Selection:
def __init__(self, id: int) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, index: int) -> Region: ...
Expand All @@ -226,14 +226,14 @@ class Selection(object):
def subtract(self, region: Region) -> None: ...
def contains(self, region: Region) -> bool: ...

class Sheet(object):
class Sheet:
def __init__(self, id: int) -> None: ...
def __eq__(self, other: Any) -> bool: ...
def id(self) -> int: ...
def window(self) -> Optional[Window]: ...
def view(self) -> Optional[View]: ...

class View(object):
class View:
def __init__(self, id: int) -> None: ...
def __len__(self) -> int: ...
def __eq__(self, other: Any) -> bool: ...
Expand Down Expand Up @@ -270,11 +270,11 @@ class View(object):
def change_count(self) -> int: ...
def run_command(self, cmd: str, args: Optional[dict] = None) -> None: ...
def sel(self) -> Selection: ...
def substr(self, x: Region) -> str: ...
def substr(self, x: Union[Region, int]) -> str: ...
def find(self, pattern: str, start_pt: int, flags: int = 0) -> Region: ...
def find_all(self, pattern: str, flags: int = 0, fmt: Optional[str] = None, extractions: Optional[list] = None) -> List[Region]: ...
def settings(self) -> Settings: ...
def meta_info(self, key: str, pt: int) -> str: ...
def meta_info(self, key: str, pt: int) -> dict: ...
def extract_tokens_with_scopes(self, r: Region) -> List[Tuple[Region, str]]: ...
def extract_scope(self, pt: int) -> Region: ...
def scope_name(self, pt: int) -> str: ...
Expand Down Expand Up @@ -355,7 +355,7 @@ class View(object):
def hide_popup(self) -> None: ...
def is_auto_complete_visible(self) -> bool: ...

class Settings(object):
class Settings:
settings_id: int

def __init__(self, id: int) -> None: ...
Expand All @@ -366,16 +366,16 @@ class Settings(object):
def add_on_change(self, tag: str, callback: Callable[[], Any]) -> None: ...
def clear_on_change(self, tag: str) -> None: ...

class Phantom(object):
class Phantom:
def __init__(self, region: Region, content: str, layout: int, on_navigate: Callable[[str], Any] = None) -> None: ...
def __eq__(self, rhs: Any) -> bool: ...

class PhantomSet(object):
class PhantomSet:
def __init__(self, view: View, key: str = "") -> None: ...
def __del__(self) -> None: ...
def update(self, new_phantoms: List[Phantom]) -> None: ...

class Html(object):
class Html:
__slots__ = ['data']

def __init__(self, data: Any) -> None: ...
Expand Down
57 changes: 35 additions & 22 deletions stubs/sublime_plugin.pyi
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
import sublime
from typing import Optional, Union, List, Dict, Tuple

from typing import Callable, Generic, TypeVar, Optional, Union, List, Tuple, overload

class CommandInputHandler():

InputType = TypeVar('InputType', bound=Union[str, int, float, list, dict, tuple, None])


class CommandInputHandler(Generic[InputType]):
def name(self) -> str: ...
def next_input(self, args: dict) -> Optional[CommandInputHandler]: ...
def placeholder(self) -> str: ...
def initial_text(self) -> str: ...
def preview(self, arg: dict) -> Union[str, sublime.Html]: ...
def validate(self, arg: dict) -> bool: ...
def preview(self, arg: InputType) -> Union[str, sublime.Html]: ...
def validate(self, arg: InputType) -> bool: ...
def cancel(self) -> None: ...
def confirm(self, arg: dict) -> None: ...

@overload
def confirm(self, arg: InputType) -> None: ...
@overload
def confirm(self, arg: InputType, event: dict) -> None: ...


class BackInputHandler(CommandInputHandler):
class BackInputHandler(CommandInputHandler[None]):
pass


class TextInputHandler(CommandInputHandler):
class TextInputHandler(CommandInputHandler[str]):
def description(self, text: str) -> str: ...


class ListInputHandler(CommandInputHandler):
def list_items(self) -> list: ...
ListItem = Union[str, Tuple[str, InputType]]


class ListInputHandler(CommandInputHandler[InputType], Generic[InputType]):
def list_items(self) -> Union[List[ListItem], Tuple[List[ListItem], int]]: ...
def description(self, v: object, text: str) -> str: ...


class Command():
class Command:
def is_enabled(self) -> bool: ...
def is_visible(self) -> bool: ...
def is_checked(self) -> bool: ...
Expand All @@ -36,23 +47,25 @@ class Command():


class ApplicationCommand(Command):
def run(self) -> None: ...
run: Callable[..., None]


class WindowCommand(Command):
window: sublime.Window

def run(self) -> None: ...
run: Callable[..., None]


class TextCommand(Command):
view: sublime.View

def run(self, edit: sublime.Edit) -> None: ...
run: Callable[..., None]
def want_event(self) -> bool: ...


class EventListener():
Completion = Union[str, Tuple[str, str], List[str]]

class EventListener:
def on_new(self, view: sublime.View) -> None: ...
def on_new_async(self, view: sublime.View) -> None: ...
def on_clone(self, view: sublime.View) -> None: ...
Expand All @@ -74,15 +87,15 @@ class EventListener():
def on_deactivated(self, view: sublime.View) -> None: ...
def on_deactivated_async(self, view: sublime.View) -> None: ...
def on_hover(self, view: sublime.View, point: int, hover_zone: int) -> None: ...
def on_query_context(self, view: sublime.View, key: str, operator: int, operand: str, match_all: bool) -> Optional[None]: ...
def on_query_completions(self, view: sublime.View, prefix: str, locations: List[int]) -> Union[None, list, tuple]: ...
def on_text_command(self, view: sublime.View, command_name: str, args: dict) -> Tuple[str, dict]: ...
def on_query_context(self, view: sublime.View, key: str, operator: int, operand: str, match_all: bool) -> Optional[bool]: ...
def on_query_completions(self, view: sublime.View, prefix: str, locations: List[int]) -> Union[None, List[Completion], Tuple[List[Completion], int]]: ...
def on_text_command(self, view: sublime.View, command_name: str, args: dict) -> Optional[Tuple[str, dict]]: ...
def on_post_text_command(self, view: sublime.View, command_name: str, args: dict) -> None: ...
def on_window_command(self, view: sublime.Window, command_name: str, args: dict) -> Tuple[str, dict]: ...
def on_window_command(self, view: sublime.Window, command_name: str, args: dict) -> Optional[Tuple[str, dict]]: ...
def on_post_window_command(self, view: sublime.Window, command_name: str, args: dict) -> None: ...


class ViewEventListener():
class ViewEventListener:
view: sublime.View

@classmethod
Expand All @@ -108,7 +121,7 @@ class ViewEventListener():
def on_deactivated_modified(self) -> None: ...
def on_deactivated_modified_async(self) -> None: ...
def on_hover(self, point: int, hover_zone: int) -> None: ...
def on_query_context(self, key: str, operator: int, operand: str, match_all: bool) -> Optional[None]: ...
def on_query_completions(self, prefix: str, locations: List[int]) -> Union[None, list, tuple]: ...
def on_text_command(self, command_name: str, args: dict) -> Tuple[str, dict]: ...
def on_query_context(self, key: str, operator: int, operand: str, match_all: bool) -> Optional[bool]: ...
def on_query_completions(self, prefix: str, locations: List[int]) -> Union[None, List[Completion], Tuple[List[Completion], int]]: ...
def on_text_command(self, command_name: str, args: dict) -> Optional[Tuple[str, dict]]: ...
def on_post_text_command(self, command_name: str, args: dict) -> None: ...