Completion giving incorrect options when editing multiline function invocation
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
Hi there! I've run into some strange behavior with respect to the completion suggestions given by `pyright-langserver` when editing an existing invocation of a function/method that's been formatted over multiple lines. This scenario only seems to manifest when the arguments being passed to the given function are attributes of some other object. I realize that this bug is quite specific and difficult to describe, so I'll be attaching some screenshots down below to hopefully do a better job of getting the point across. The issue is that if an additional argument is added anywhere but the end of the existing arguments, then pyright seems to suggest every symbol that's defined in the global scope as an attribute of the object in question.
**Code or Screenshots**
Here's a simple reproduction case:
```python
class User:
id: int = 0
age: int = 0
name: str = "user"
my_user = User()
def test(*args: int | str) -> None: ...
test(
my_user.age,
my_user.id,
)
```
If I'm editing the above snippet and decide that I want to add the `my_user.name` field to the existing call to `test(...)`, then unless I add it as the final argument I get the following behavior:
Every symbol that's currently defined populates the list of suggestions, including Python keywords/exceptions/built-ins. If I instead add the extra argument as the last line of the function call instead, then I get the expected list of suggestions:
Again, when writing such a function invocation for the first time there are no issues, it's only when going back and editing is there a problem. Maybe because when writing the invocation you're always editing the final argument? I've tested this with non-variadic functions and with built in python objects like dictionaries instead of user-defined classes as in my above example and I see the same behavior.
**VS Code extension or command-line**
I've tested this both in VS Code using the pylance extension v2025.8.3, and with `pyright-langserver 1.1.406` acting as a language server in neovim. For VS Code I was using the following:
```
Version: 1.105.0 (user setup)
Commit: 03c265b1adee71ac88f833e065f7bb956b60550a
Date: 2025-10-08T14:09:35.891Z
Electron: 37.6.0
ElectronBuildId: 12502201
Chromium: 138.0.7204.251
Node.js: 22.19.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.19045
```
Contributor guide
Research direction
Reproduce the behavior with the provided User class and multiline test(...) invocation using pyright-langserver 1.1.406, then compare completion results when inserting an argument in the middle versus at the end. Trace the completion request and argument context handling in the language-server completion path. Done means editing an existing multiline call produces relevant attribute suggestions rather than global symbols, with regression coverage for this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100