vscode-python: Autocompletion per PEP 526 Type Annotations Not Working For List[x] where x is int, str, etc...
Environment data
- VS Code version: 1.26.1
- Extension version (available under the Extensions sidebar): 2018.7.1
- OS and version: macOS 10.13.6
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.0 (pyenv, miniconda)
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda, pyenv
- Relevant/affected Python packages and their versions: NA
Actual behavior
Type hinting not working for some PEP 526 style annotations (in my case List[?] does not work)

Expected behavior
Type hinting to recognize variable type annotations in the function declaration. Screenshot below of what I would expect from above (note in the function declaration I did not specify the type in the list).

Steps to reproduce:
-
Create new python file
-
Specify any Python 3.6+ interpretter
-
fill out
from typing import List def foo(a: List[int]): a.# now wait for auto-complete
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
Starting Microsoft Python language server.
[Info - 3:56:19 PM] Created Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreter instance from Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory
Initializing for /Users/ogi/.pyenv/versions/miniconda3-latest/bin/python
[Info - 3:57:41 PM] Found 198 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (1, 2) after filtering
[Info - 3:57:42 PM] Found 334 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (1, 7) after filtering
[Info - 3:57:43 PM] Found 1 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (1, 14) after filtering
[Info - 3:57:44 PM] Found 119 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (1, 21) after filtering
[Info - 3:57:45 PM] Found 119 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (1, 21) after filtering
[Info - 3:57:47 PM] Found 199 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (3, 2) after filtering
[Info - 3:57:50 PM] Found 182 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (3, 13) after filtering
[Info - 3:57:52 PM] Found 182 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (3, 18) after filtering
[Info - 3:57:54 PM] Found 204 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (4, 6) after filtering
[Info - 3:57:54 PM] Found 2 completions for file:///Users/ogi/Academic/CS532/demo/test.py at (4, 7) after filtering
Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)
workbench.main.js:sourcemap:1397 INFO no standard startup: panel is active
workbench.main.js:sourcemap:4188 Overwriting grammar scope name to file mapping for scope source.swift.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/swift/syntaxes/swift.tmLanguage.json.
New grammar file: file:///Users/ogi/.vscode/extensions/Kasik96.swift-0.0.3/syntaxes/swift.tmLanguage
e.register @ workbench.main.js:sourcemap:4188
workbench.main.js:sourcemap:1398 ERR Illegal argument: character must be non-negative: Error: Illegal argument: character must be non-negative
at Object.t.illegalArgument (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:95:675)
at new e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:472:92)
at e.translate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:473:725)
at getPrecedingRange (/Users/ogi/.vscode/extensions/njpwerner.autodocstring-0.2.3/src/extension.ts:55:39)
at processEnter (/Users/ogi/.vscode/extensions/njpwerner.autodocstring-0.2.3/src/extension.ts:41:17)
at activateOnEnter (/Users/ogi/.vscode/extensions/njpwerner.autodocstring-0.2.3/src/extension.ts:35:9)
at context.subscriptions.push.vs.workspace.onDidChangeTextDocument.changeEvent (/Users/ogi/.vscode/extensions/njpwerner.autodocstring-0.2.3/src/extension.ts:23:34)
at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:98:218)
at e.$acceptModelChanged (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:728:571)
at e._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:671:983)
at e._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:671:701)
at e._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:670:767)
at e._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:670:536)
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:669:452
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:672:575
at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:96:903
at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:98:218)
at a (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:162:713)
at Socket._socketDataListener (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:162:932)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
2workbench.main.js:sourcemap:1398 ERR Cannot read property 'map' of null: TypeError: Cannot read property 'map' of null
at asCompletionResult (/Users/ogi/.vscode/extensions/ms-python.python-2018.7.1/node_modules/vscode-languageclient/lib/protocolConverter.js:145:51)
at <anonymous>
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 17 (4 by maintainers)
I can replicate this.
@MikhailArkhipov can’t quite decide if I want to make this a P1 since a decent amount of type hints will be a generic like this, but it also doesn’t crash the language server or prevent it from working otherwise.
https://github.com/Microsoft/python-language-server/pull/321
@egabrum that’s the case I’m seeing too.