no intelliSense for python namedtuple #2377
Copy link
Copy link
Closed
Labels
area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug
Description
Environment data
- VS Code version: 1.25.1
- Extension version (available under the Extensions sidebar): python2018.7.1
- OS and version: windows10
- Python version (& distribution if applicable, e.g. Anaconda): python3.6.5
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
with config "python.jediEnabled": false
Actual behavior
from collections import namedtuple
RequestStartLine = namedtuple("RequestStartLine", "method path version".split())
start_line = RequestStartLine("GET", "/query", "HTTP/1.1")
print(start_line)
start_line. # <- no suggestion
Reacted by Stav, Andrei Sinitson and Mike Borozdin
Metadata
Metadata
Assignees
Labels
area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug
Activity
[-]no intelliSense for python regular expression: re[/-][+]no intelliSense for python namedtuple[/+]purpleP commentedon Aug 12, 2018
chen19901225 This was discussed in my issue #2259
brettcannon commentedon Aug 13, 2018
It should be noted that supporting namedtuple for IntelliSense requires special handling due to how the module dynamically generates code.
purpleP commentedon Aug 13, 2018
Brett Cannon (@brettcannon) well, there's
evalinnamedtuplebut it's harmless. If you're simulating code execution why exactly you can't simulate thatevalalso? You know, I get why pycharm haven't hadnamedtupleautocompletion for a long time. They only use static analysis, so they really have to use special handling here otherwise they would need basically emulate the whole interpreter to understand what thisevalwill do at runtime. But you claim that you have some simulation going on. So maybe you could just simulate code execution fornamedtupleand inspect its output?MikhailArkhipov commentedon Aug 13, 2018
purpleP - code in libraries goes through lighter weight evaluation (as compared to user code) since otherwise performance suffers. In VS there used to be long process of building the library database. BTW, PyCharm does eval too ('building index...') but it also has a number of pre-cooked modules/heuristics for some common things.
We just need to improve the eval.
DonJayamanne commentedon Aug 14, 2018
Changing the labels, as this works when using Jedi.
I.e. if it works in Jedi and not in language server, then its a bug and we should try to fix it in the language server.
louisabraham commentedon May 31, 2019
Hi, I have this issue as well.
Just wanted to remark that
typing.NamedTupleshould be used instead.luabud commentedon Sep 11, 2019
Closing as this isn't an extension issue. If you encounter this problem, please file an issue on the Language Server repo