-
Notifications
You must be signed in to change notification settings - Fork 133
VSCode Python Extention giving undefined variable warnings for defined variables in 2020.2.63072 #1908
Comments
As far as I know, we haven't made any changes surrounding this, but it seems like some of the platform checks which we use when processing stubs may be getting applied incorrectly. In general in real python code, we don't enforce platform checks. Undefined variable checking is a second pass over the code, so the first pass may not be walking everything. |
Same problem here in OSX, latest VSCode version with jedi disabled. |
Here linter walks both |
Same on Arch Linux and Code - OSS Good luck 😁 |
Ok, wow, today is 19.01.2021 and i ran into this issue. A lot of Variables are marked as not defined and Debugging is not possible through this. Will this issue ever be resolved? |
It left all by itself for me 👍 |
Chronic problem here, doesn't even require conditional expressions to be involved. Simple class methods with local variables trigger these warnings.. Sometimes just deleting/re-pasting a line in the file fixes the problem. |
The issue still persists, on macOS Big Sur 11.4. |
my issue was fixed after i converted all indentation to spaces |
I am still seeing this bug on windows. Now it also throws proper errors that stop the code. FYI, it's a .py file with Jupyter notebook style markdown and cells. |
This repo is no longer maintained, and will soon be deprecated. https://devblogs.microsoft.com/python/python-in-visual-studio-code-september-2021-release/#microsoft-python-language-server-end-of-life-november-2021 You should be seeing warnings of this if you still have your language server set to "Microsoft". |
Thank you for the report. This project is no longer active. If you are using the Python language server in VSCode, the language server you are using is Pylance and please the http://github.com/microsoft/pylance-release to report issues. If you are using Visual Studio, then, please use http://github.com/microsoft/PTVS to report issues. thank you |
Good Afternoon,
i think there may be an bug on the latest release of the Python extention for VSC that results in warnings being given suggesting varibables are undefined when the variables are defined.
ive been using VSCode with the python extention for a while and after updating the python extention today (to 2020.2.63072) i now have 34 warnings in my code for undefined variables. my problem is that they are all defined, the code works as it did before i updated the extention and as i would expect it to.
if i revert the python extention back to version 2020.1.58038 i dont get the warnings, update from that to 2020.2.62710 or 2020.2.63072 and both are giving me warnings.
Ive tried removing all extentions and reinstalling VSC, all without success. Im currently running VSC with only one user installed extention, that is the Python 2020.2.63072 extention.
Below is an example piece of code that throws such a warning for me . in my project i use similar methods whereby i run certain code depending on the environment in which it is run (its intended to run on a raspberry pi with camera, but can be run on windows, for pi i import the picamera modules and support capturing images with the camera, for windows that feature is disabled but the rest of the code runs). The code below reproduces what i think is the bug.
With that code, VSC lists a warning that aVariable is undefined within the linux check, (line 5) . There is no such warning given at line 9 which would trigger if not linux. as i mention above if i move back to an older version of the Python extention this warning is not given.
Im running VSC on Windows 10, and my suspicion is that where i have variables declared and referenced only after a given condition is met, then if that condition is not met within the environment for which i am writing the code, the warnings are generated. e.g. within the if statement to check if this is linux, i get an undeclared variable warning if im writing the code on a windows machine. i dont believe this should happen, and doesnt happen on older versions of the extention.
i have noted that when i switch versions on this extention, the MPLS is redownloaded in the background. im not sure how to obtain the version number for MPLS to be able to post here? My appologies, im new to CSV and Python
Environment data
"python.jediEnabled"
set to; more info How to update the language server to the latest stable version vscode-python#3977): MPLSpython.languageServer
setting: XXXThe text was updated successfully, but these errors were encountered: