Declare variables from unresolved imports as Unknown rather than not defining them
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).
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
What is your language server version? (The extension and the language server are versioned and updated independently.)
ms-python.python-2019.3.6558 languageServer.0.2.55
Yes, currently unresolved import causes the respective variables not being defined.
We can declare it as unknown type.