From 2bd2abc867219987ba9d62c504c09fc15b8e2d24 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Tue, 12 Dec 2023 22:46:06 +0100 Subject: [PATCH 1/6] fix minor stub type issues detected by mypy --- pyrightconfig.json | 1 + stubs/sublime.pyi | 22 +++++++++++----------- stubs/sublime_plugin.pyi | 6 +++--- tox.ini | 10 +++++----- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 8bb1fb61a..a2ad8fc9e 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -1,5 +1,6 @@ { "pythonVersion": "3.11", "reportMissingModuleSource": "none", + "reportIncompatibleMethodOverride": "none", "stubPath": "./stubs", } diff --git a/stubs/sublime.pyi b/stubs/sublime.pyi index 2c3395bc3..78d607ae9 100644 --- a/stubs/sublime.pyi +++ b/stubs/sublime.pyi @@ -704,7 +704,7 @@ class Window: """ ... - def hwnd(self): + def hwnd(self) -> int: """ A platform specific window handle. Windows only. """ @@ -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: @@ -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. """ @@ -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 ... @@ -1388,7 +1388,7 @@ class Selection(Reversible): """ ... - def __eq__(self, rhs: Selection | None) -> bool: + def __eq__(self, rhs: object) -> bool: """ Whether the selections are identical. """ @@ -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`. @@ -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. @@ -2471,7 +2471,7 @@ class View: def export_to_html( self, - regions=None, + regions: Optional[Region | List[Region]] = None, minihtml: bool = ..., enclosing_tags: bool = ..., font_size: bool = ..., @@ -2614,7 +2614,7 @@ class Phantom: ) -> None: ... - def __eq__(self, rhs: 'Phantom') -> bool: + def __eq__(self, rhs: object) -> bool: ... def to_tuple(self) -> Tuple[Tuple[int, int], str, int, Optional[Callable[[str], None]]]: @@ -2726,7 +2726,7 @@ class CompletionItem: ) -> None: ... - def __eq__(self, rhs: 'CompletionItem') -> bool: + def __eq__(self, rhs: object) -> bool: ... @classmethod diff --git a/stubs/sublime_plugin.pyi b/stubs/sublime_plugin.pyi index 50945641c..eec001c23 100644 --- a/stubs/sublime_plugin.pyi +++ b/stubs/sublime_plugin.pyi @@ -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 @@ -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. @@ -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. """ diff --git a/tox.ini b/tox.ini index dfac4e00a..f54a0a228 100644 --- a/tox.ini +++ b/tox.ini @@ -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 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 From ccfbc7f2307955ed953f7a7ecf623111e8d3f7d2 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Wed, 13 Dec 2023 09:22:51 +0100 Subject: [PATCH 2/6] ignore eq issues --- stubs/sublime.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/sublime.pyi b/stubs/sublime.pyi index 78d607ae9..4d9df37b0 100644 --- a/stubs/sublime.pyi +++ b/stubs/sublime.pyi @@ -1388,7 +1388,7 @@ class Selection(Reversible): """ ... - def __eq__(self, rhs: object) -> bool: + def __eq__(self, rhs: Selection | None) -> bool: # type: ignore[override] """ Whether the selections are identical. """ @@ -2614,7 +2614,7 @@ class Phantom: ) -> None: ... - def __eq__(self, rhs: object) -> bool: + def __eq__(self, rhs: 'Phantom') -> bool: # type: ignore[override] ... def to_tuple(self) -> Tuple[Tuple[int, int], str, int, Optional[Callable[[str], None]]]: @@ -2726,7 +2726,7 @@ class CompletionItem: ) -> None: ... - def __eq__(self, rhs: object) -> bool: + def __eq__(self, rhs: 'CompletionItem') -> bool: # type: ignore[override] ... @classmethod From 87aa5389bc6134570755d76c1814cce0e57666b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Wed, 13 Dec 2023 09:37:38 +0100 Subject: [PATCH 3/6] Update stubs/sublime.pyi Co-authored-by: jwortmann --- stubs/sublime.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/sublime.pyi b/stubs/sublime.pyi index 4d9df37b0..ca05246e3 100644 --- a/stubs/sublime.pyi +++ b/stubs/sublime.pyi @@ -2614,7 +2614,7 @@ class Phantom: ) -> None: ... - def __eq__(self, rhs: 'Phantom') -> bool: # type: ignore[override] + def __eq__(self, rhs: Phantom) -> bool: # type: ignore[override] ... def to_tuple(self) -> Tuple[Tuple[int, int], str, int, Optional[Callable[[str], None]]]: From c5a92a72db9ecd06bce5e43ccad54036cff333f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Wed, 13 Dec 2023 09:37:45 +0100 Subject: [PATCH 4/6] Update stubs/sublime.pyi Co-authored-by: jwortmann --- stubs/sublime.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/sublime.pyi b/stubs/sublime.pyi index ca05246e3..40bd5fbca 100644 --- a/stubs/sublime.pyi +++ b/stubs/sublime.pyi @@ -2726,7 +2726,7 @@ class CompletionItem: ) -> None: ... - def __eq__(self, rhs: 'CompletionItem') -> bool: # type: ignore[override] + def __eq__(self, rhs: CompletionItem) -> bool: # type: ignore[override] ... @classmethod From c5bb99020123c887e3563395989f45f34286804d Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Wed, 13 Dec 2023 09:39:53 +0100 Subject: [PATCH 5/6] sync versions in CI --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 21b9321d4..4226f7909 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,8 +40,8 @@ jobs: python-version: '3.8' - run: sudo apt update - run: sudo apt install --no-install-recommends -y x11-xserver-utils - - run: pip3 install mypy==0.971 flake8==5.0.4 pyright==1.1.335 yapf==0.31.0 --user + - run: pip3 install mypy==1.7.1 flake8==5.0.4 pyright==1.1.339 --user - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - # - run: mypy -p plugin + - run: mypy stubs - run: flake8 plugin tests - run: pyright plugin From 640d1f42b026b5e98b1938e87b3b968f4b086ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Wed, 13 Dec 2023 10:19:35 +0100 Subject: [PATCH 6/6] Update stubs/sublime.pyi Co-authored-by: jwortmann --- stubs/sublime.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/sublime.pyi b/stubs/sublime.pyi index 40bd5fbca..684d74184 100644 --- a/stubs/sublime.pyi +++ b/stubs/sublime.pyi @@ -2471,7 +2471,7 @@ class View: def export_to_html( self, - regions: Optional[Region | List[Region]] = None, + regions: Region | List[Region] | None = ..., minihtml: bool = ..., enclosing_tags: bool = ..., font_size: bool = ...,