Request textDocument/completion failed on custom code
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
Hello, I'm trying to create a decorator that will "copy the kwarg types" of a function to another (code below).
However, I am facing the following issue:
```
[Error - 9:52:33 PM] Request textDocument/completion failed.
Message: Request textDocument/completion failed with message: Debug Failure. False expression.
Code: -32603
```
**Code or Screenshots**
If possible, provide a minimal, self-contained code sample (surrounded by triple back ticks) to demonstrate the issue. The code should define or import all referenced symbols.
```python
from typing import Protocol, Generic, ParamSpec, TypeVar, Any, Callable
F1 = ParamSpec("F1")
F2 = ParamSpec("F2")
R = TypeVar("R", covariant=True)
class FunctionWithKwargs(Protocol, Generic[F1, F2, R]):
def __call__(*args: F2.args, **kwargs: F1.kwargs) -> R: ...
def copy_kwargs_types(
_: Callable[F1, Any],
) -> Callable[[Callable[F2, R]], FunctionWithKwargs[F1, F2, R]]:
return lambda x: x # type: ignore
def f(*, b: int, c: str) -> None:
pass
@copy_kwargs_types(f)
def g(a, **kwargs) -> None:
...
g() # <- Issue happens here
```
**VS Code extension or command-line**
I am running the VSCode extension.
Contributor guide
Research direction
Reproduce the sample in the VS Code extension and trigger completion at the marked g() call. Start by tracing the textDocument/completion request associated with the reported Debug Failure. Done means completion no longer crashes on this decorator, ParamSpec, and Protocol combination; validate the behavior with the supplied self-contained example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100