-
Notifications
You must be signed in to change notification settings - Fork 32
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
auto-import completions for a submodule of a package when the package is already imported #992
Comments
which editor are you using? or are you using your own LSP client? |
I don't think it's working for me. I'm using my own LSP client. I'll try to put together a simple reproducible script. |
there are two issues here. the first is that requesting completions at the end of the completed module name won't return anything because the name is already there: it works if you add a but those completions suck because there's another problem here. in your script the code you're requesting completions for is: import sklearn
sklearn.datasets the above code imports the import sklearn
reveal_type(sklearn.datasets) # ModuleType | Any therefore the type information is lost which is why you aren't seeing any useful completions: if you import the import sklearn.datasets
reveal_type(sklearn.datasets) # Module("sklearn.datasets") i fixed these two issues in your script and now it returns the correct completions: # Open document
- test_code = "import sklearn\nsklearn.datasets"
+ test_code = "import sklearn.datasets\nsklearn.datasets."
doc_uri = "untitled:/test.py"
if platform.system() == "Windows":
doc_uri += "/" # needed on Windows
await ls.send_message({
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": doc_uri,
"languageId": "python",
"version": 1,
"text": test_code
}
}
})
# Send completion request
ls.completion_request_id = str(uuid.uuid4())
await ls.send_message({
"jsonrpc": "2.0",
"id": ls.completion_request_id,
"method": "textDocument/completion",
"params": {
"textDocument": {"uri": doc_uri},
- "position": {"line": 1, "character": 16}
+ "position": {"line": 1, "character": 17}
}
}) |
I understand that you have to do But I'd like the import completion for import sklearn
sklearn.datasets it should suggest importing |
I'm familiar with sending requests like
textDocument/signatureHelp
andtextDocument/completion
.If I have
basedpyright.analysis.autoImportCompletions
set to true, what request type should I send to get import completions?Thanks!
The text was updated successfully, but these errors were encountered: