From 2aa5d3c438146b9b19694ec308d32acb45dbf080 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Wed, 1 Nov 2023 07:46:37 +0100 Subject: [PATCH 1/5] Upgrade pyright --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index cd782f96a..01649ff46 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ per-file-ignores = deps = ; mypy==0.971 flake8==5.0.4 - pyright==1.1.289 + pyright==1.1.334 commands = # mypy disabled as it doesn't currently support cyclic definitions - https://github.com/python/mypy/issues/731 ; mypy plugin From 633a4dffd5c61fa3163fffe3a3b3dcf39db8bd95 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Wed, 1 Nov 2023 07:47:02 +0100 Subject: [PATCH 2/5] Ignore new type errors --- plugin/core/promise.py | 2 +- plugin/core/sessions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/core/promise.py b/plugin/core/promise.py index 4e68b400b..d78ae67e6 100644 --- a/plugin/core/promise.py +++ b/plugin/core/promise.py @@ -169,7 +169,7 @@ def callback_wrapper(resolve_fn: ResolveFunc[TResult], resolve_value: T) -> None # If returned value is a promise then this promise needs to be # resolved with the value of returned promise. if isinstance(result, Promise): - result.then(lambda value: resolve_fn(value)) + result.then(lambda value: resolve_fn(value)) # type: ignore # TODO fix me else: resolve_fn(result) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 2e538f5b4..09a2e1299 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1489,7 +1489,7 @@ def _handle_initialize_success(self, result: InitializeResult) -> None: self._workspace_folders = self._workspace_folders[:1] self.state = ClientStates.READY if self._plugin_class is not None: - self._plugin = self._plugin_class(weakref.ref(self)) + self._plugin = self._plugin_class(weakref.ref(self)) # type: ignore # TODO fix me # We've missed calling the "on_server_response_async" API as plugin was not created yet. # Handle it now and use fake request ID since it shouldn't matter. self._plugin.on_server_response_async('initialize', Response(-1, result)) From a6988e7a6e195e86f5d3c2492bc42f793f841c10 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Thu, 2 Nov 2023 13:48:48 +0100 Subject: [PATCH 3/5] Update GitHub CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ed6bbedc..0fb9643b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ 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.289 yapf==0.31.0 --user + - run: pip3 install mypy==0.971 flake8==5.0.4 pyright==1.1.334 yapf==0.31.0 --user - run: echo "$HOME/.local/bin" >> $GITHUB_PATH # - run: mypy -p plugin - run: flake8 plugin tests From f465a57566a9a86741b60e0ba126a16f90a77d92 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Sun, 5 Nov 2023 09:04:46 +0100 Subject: [PATCH 4/5] Try to fix the type errors --- plugin/core/promise.py | 4 ++-- plugin/core/sessions.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/core/promise.py b/plugin/core/promise.py index d78ae67e6..86bddddec 100644 --- a/plugin/core/promise.py +++ b/plugin/core/promise.py @@ -14,7 +14,7 @@ def __call__(self, resolve_value: T_contra) -> None: ... -FullfillFunc = Callable[[T], Union[TResult, 'Promise[TResult]']] +FullfillFunc = Callable[[T], Union['Promise[TResult]', TResult]] ExecutorFunc = Callable[[ResolveFunc[T]], None] PackagedTask = Tuple['Promise[T]', ResolveFunc[T]] @@ -169,7 +169,7 @@ def callback_wrapper(resolve_fn: ResolveFunc[TResult], resolve_value: T) -> None # If returned value is a promise then this promise needs to be # resolved with the value of returned promise. if isinstance(result, Promise): - result.then(lambda value: resolve_fn(value)) # type: ignore # TODO fix me + result.then(lambda value: resolve_fn(value)) else: resolve_fn(result) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 09a2e1299..cac7eb140 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1489,7 +1489,7 @@ def _handle_initialize_success(self, result: InitializeResult) -> None: self._workspace_folders = self._workspace_folders[:1] self.state = ClientStates.READY if self._plugin_class is not None: - self._plugin = self._plugin_class(weakref.ref(self)) # type: ignore # TODO fix me + self._plugin = self._plugin_class(weakref.ref(cast(Session, self))) # We've missed calling the "on_server_response_async" API as plugin was not created yet. # Handle it now and use fake request ID since it shouldn't matter. self._plugin.on_server_response_async('initialize', Response(-1, result)) From f40c926d75f0ad4e5f882b263fa38db86b6f131f Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Wed, 8 Nov 2023 13:33:15 +0100 Subject: [PATCH 5/5] Upgrade pyright to unbugged version --- .github/workflows/main.yml | 2 +- plugin/core/promise.py | 2 +- plugin/core/sessions.py | 2 +- tox.ini | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0fb9643b8..a7cf6bd27 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ 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.334 yapf==0.31.0 --user + - run: pip3 install mypy==0.971 flake8==5.0.4 pyright==1.1.335 yapf==0.31.0 --user - run: echo "$HOME/.local/bin" >> $GITHUB_PATH # - run: mypy -p plugin - run: flake8 plugin tests diff --git a/plugin/core/promise.py b/plugin/core/promise.py index 86bddddec..4e68b400b 100644 --- a/plugin/core/promise.py +++ b/plugin/core/promise.py @@ -14,7 +14,7 @@ def __call__(self, resolve_value: T_contra) -> None: ... -FullfillFunc = Callable[[T], Union['Promise[TResult]', TResult]] +FullfillFunc = Callable[[T], Union[TResult, 'Promise[TResult]']] ExecutorFunc = Callable[[ResolveFunc[T]], None] PackagedTask = Tuple['Promise[T]', ResolveFunc[T]] diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index cac7eb140..2e538f5b4 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1489,7 +1489,7 @@ def _handle_initialize_success(self, result: InitializeResult) -> None: self._workspace_folders = self._workspace_folders[:1] self.state = ClientStates.READY if self._plugin_class is not None: - self._plugin = self._plugin_class(weakref.ref(cast(Session, self))) + self._plugin = self._plugin_class(weakref.ref(self)) # We've missed calling the "on_server_response_async" API as plugin was not created yet. # Handle it now and use fake request ID since it shouldn't matter. self._plugin.on_server_response_async('initialize', Response(-1, result)) diff --git a/tox.ini b/tox.ini index 01649ff46..dfac4e00a 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ per-file-ignores = deps = ; mypy==0.971 flake8==5.0.4 - pyright==1.1.334 + pyright==1.1.335 commands = # mypy disabled as it doesn't currently support cyclic definitions - https://github.com/python/mypy/issues/731 ; mypy plugin