Skip to content

Language Server incorrectly marks variables as undefined in nested list comprehensions #3297

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

Closed
mawright opened this issue Nov 11, 2018 · 5 comments
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@mawright
Copy link

Environment data

  • VS Code version: 1.28.2
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: Ubuntu 16.04
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda 3.6.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: N/A

Actual behavior

screenshot from 2018-11-10 19-32-37

Expected behavior

Linter does not incorrectly mark variable as undeclared

Steps to reproduce:

  1. See screenshot

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
Microsoft Python Language Server version 0.1.60.0
Initializing for /home/matt/anaconda3/envs/learn/bin/python

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:1409  INFO no standard startup: not a new window
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:4274 Overwriting grammar scope name to file mapping for scope source.python.
Old grammar file: file:///usr/share/code/resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json.
New grammar file: file:///home/matt/.vscode/extensions/magicstack.magicpython-1.1.0/grammars/MagicPython.tmLanguage
e.register @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:4274
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] vscode-icons is active!
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Create file systemwatcher with pattern */python
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Create file systemwatcher with pattern */*/python
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: undefined, Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: undefined, Return Value: UNABLE TO DETERMINE VALUE
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Get language server folder name, , Return Value: "languageServer.0.1.60"
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Git extension API method 'getGitPath' is deprecated.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:282 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
@darrickyee
Copy link

I think this is a language server issue, not a linting issue. The message is not prefixed with [pylint] and still appears when pylint is disabled.

@DonJayamanne
Copy link

This issue was moved to microsoft/python-language-server#387

@DonJayamanne DonJayamanne reopened this Nov 12, 2018
@DonJayamanne DonJayamanne changed the title Linter doesn't understand nested list comprehensions, incorrectly marks variables as undefined c Nov 12, 2018
@DonJayamanne DonJayamanne changed the title c Language Server incorrectly marks variables as undefined in nested list comprehensions Nov 12, 2018
@brettcannon brettcannon self-assigned this Nov 13, 2018
@brettcannon brettcannon added triage bug Issue identified by VS Code Team member as probable bug area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. and removed triage labels Nov 13, 2018
@brettcannon brettcannon removed their assignment Nov 14, 2018
@marvingreenberg
Copy link

marvingreenberg commented Apr 2, 2019

I have a probably related problem, not exactly an issue of nesting. It is occurring only on a return though.

x = {}
def fn(a,b):
    return (a,b)
def foo():
     y = [ fn(a,b) for a,b in x.items() ]                # no issue
     return [ fn(a,b) for a,b in x.items() ]             # Shows a,b as undefined variables

This is ms-python.python 2019.3.6215

The reported issue is (for a and b)
Undefined variable: 'a' Python(undefined-variable)

@brettcannon
Copy link
Member

@luabud
Copy link
Member

luabud commented Sep 11, 2019

Original issue was fixed upstream (microsoft/python-language-server#387)

@luabud luabud closed this as completed Sep 11, 2019
@ghost ghost removed the needs upstream fix label Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

6 participants