Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some mypy type issues in stubs #2374

Merged
merged 6 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"pythonVersion": "3.11",
"reportMissingModuleSource": "none",
"reportIncompatibleMethodOverride": "none",
"stubPath": "./stubs",
}
22 changes: 11 additions & 11 deletions stubs/sublime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ class Window:
"""
...

def hwnd(self):
def hwnd(self) -> int:
"""
A platform specific window handle. Windows only.
"""
Expand Down Expand Up @@ -944,14 +944,14 @@ class Window:
"""
...

def layout(self):
def layout(self) -> Dict[str, Any]:
"""
Get the group layout of the window.
"""
...

@deprecated("Use layout() instead")
def get_layout(self):
def get_layout(self) -> Dict[str, Any]:
...

def set_layout(self, layout: Dict[str, Any]) -> None:
Expand Down Expand Up @@ -1145,7 +1145,7 @@ class Window:
"""
...

def template_settings(self):
def template_settings(self) -> Settings:
"""
Per-window settings that are persisted in the session, and duplicated into new windows.
"""
Expand Down Expand Up @@ -1349,7 +1349,7 @@ class TextChange:
str: str
"""A string of the new contents of the region specified by `a` and `b`."""

def __init__(self, pa: HistoricPosition, pb: HistoricPosition, len_utf16: int, len_utf8: int, s: str) -> None:
def __init__(self, pa: HistoricPosition, pb: HistoricPosition, len_utf16: int, len_utf8: int, s: str) -> None: # type: ignore[valid-type] # noqa
...


Expand Down Expand Up @@ -1388,7 +1388,7 @@ class Selection(Reversible):
"""
...

def __eq__(self, rhs: Selection | None) -> bool:
def __eq__(self, rhs: Selection | None) -> bool: # type: ignore[override]
"""
Whether the selections are identical.
"""
Expand Down Expand Up @@ -1929,7 +1929,7 @@ class View:
"""
...

def style(self):
def style(self) -> Dict[str, str]:
"""
The global style settings for the view. All colors are normalized to the six character hex form with a leading
hash, e.g. `#ff0000`.
Expand Down Expand Up @@ -2462,7 +2462,7 @@ class View:
"""
...

def preserve_auto_complete_on_focus_lost(self):
def preserve_auto_complete_on_focus_lost(self) -> None:
"""
Sets the auto complete popup state to be preserved the next time the `View` loses focus. When the `View` regains
focus, the auto complete window will be re-shown, with the previously selected entry pre-selected.
Expand All @@ -2471,7 +2471,7 @@ class View:

def export_to_html(
self,
regions=None,
regions: Optional[Region | List[Region]] = None,
rchl marked this conversation as resolved.
Show resolved Hide resolved
minihtml: bool = ...,
enclosing_tags: bool = ...,
font_size: bool = ...,
Expand Down Expand Up @@ -2614,7 +2614,7 @@ class Phantom:
) -> None:
...

def __eq__(self, rhs: 'Phantom') -> bool:
def __eq__(self, rhs: 'Phantom') -> bool: # type: ignore[override]
rchl marked this conversation as resolved.
Show resolved Hide resolved
...

def to_tuple(self) -> Tuple[Tuple[int, int], str, int, Optional[Callable[[str], None]]]:
Expand Down Expand Up @@ -2726,7 +2726,7 @@ class CompletionItem:
) -> None:
...

def __eq__(self, rhs: 'CompletionItem') -> bool:
def __eq__(self, rhs: 'CompletionItem') -> bool: # type: ignore[override]
rchl marked this conversation as resolved.
Show resolved Hide resolved
...

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions stubs/sublime_plugin.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CommandInputHandler:
"""
...

def next_input(self, args) -> CommandInputHandler | None:
def next_input(self, args: Any) -> CommandInputHandler | None:
"""
Return the next input after the user has completed this one. May return
:py:`None` to indicate no more input is required, or
Expand Down Expand Up @@ -119,7 +119,7 @@ class ListInputHandler(CommandInputHandler):
"""
...

def description(self, value, text: str) -> str:
def description(self, value: Any, text: str) -> str:
"""
The text to show in the Command Palette when this input handler is not at the top of the input handler stack.
Defaults to the text of the list item the user selected.
Expand Down Expand Up @@ -221,7 +221,7 @@ class TextCommand(Command):
def __init__(self, view: View) -> None:
...

def run(self, edit: Edit, **kwargs: Dict[str, Any]) -> None:
def run(self, edit: Edit, **kwargs: Dict[str, Any]) -> None: # type: ignore[override]
"""
Called when the command is run. Command arguments are passed as keyword arguments.
"""
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ per-file-ignores =

[testenv]
deps =
; mypy==0.971
mypy==1.7.1
flake8==5.0.4
pyright==1.1.335
pyright==1.1.339
jwortmann marked this conversation as resolved.
Show resolved Hide resolved
commands =
# mypy disabled as it doesn't currently support cyclic definitions - https://github.com/python/mypy/issues/731
; mypy plugin
# mypy disabled for main code as it doesn't currently support cyclic definitions - https://github.com/python/mypy/issues/731
mypy stubs
flake8 plugin tests
pyright plugin
pyright plugin stubs