python-language-server icon indicating copy to clipboard operation
python-language-server copied to clipboard

Declare variables from unresolved imports as Unknown rather than not defining them

Open tpajenkamp-dspace opened this issue 7 years ago • 5 comments

Environment Visual Studio CodeVersion: 1.33.1 Python Extension Version: 2019.3.6558 OS: Windows 10 Python version: 2.7/3.6 Language Server Version: 0.2.47.0

Actual Behavior Given the Python script

import clr
from System import String

def foo():
    l = String("foo")
    return String("foo")

if __name__ == "__main__":
    print(foo())

The line from System import String reports the problem "unresolved import 'System' Python(unresolved-import) [2, 6]" The line return String("foo") reports the problem "Undefined variable: 'String' Python(undefiend-variable) [6, 12]".

Expected Behavior The "unresolved-import" warning is expected, but the "undefined-variable" is unexpected to me. Interestingly, l = String("foo") is no problem (with 0.2.55.0 [beta], this line is also reported).

tpajenkamp-dspace avatar Apr 15 '19 09:04 tpajenkamp-dspace

I'm seeing the same thing. Numerous undefined-variable and unresolved-import warnings in the Problems output console with Python Extension Version 2019.3.6558

I don't have those issues with 2019.3.6215

dmayo77 avatar Apr 16 '19 14:04 dmayo77

What is your language server version? (The extension and the language server are versioned and updated independently.)

jakebailey avatar Apr 16 '19 16:04 jakebailey

ms-python.python-2019.3.6558 languageServer.0.2.55

dmayo77 avatar Apr 16 '19 16:04 dmayo77

Yes, currently unresolved import causes the respective variables not being defined.

MikhailArkhipov avatar Apr 17 '19 00:04 MikhailArkhipov

We can declare it as unknown type.

MikhailArkhipov avatar Oct 01 '19 17:10 MikhailArkhipov