True/False being reported as undefined #391
Comments
I have a fix for the The True/False issue is likely some racy behavior where we do analysis before the builtins are finished (something I've been unable to reproduce). |
I reported the original issue on the vscode-python tracker. I can reliably reproduce this issue every time I open my (fairly large) python 2.7 project. The True/False identifiers are only marked use before ref once the project has finished being analyzed. That said, this particular project is also prone to maxing out CPU and constantly growing RAM (with the language server) so perhaps those two things are related. |
Is your project open source where we could test it out? I personally have only been able to make it happen once, and never again. I've tested on a number of large repos to no avail. My current thinking is that there's some race or bug that's allowing analysis to happen before we analyze the builtins themselves. For a large project which takes a long time to work, it may exasperate the issue (and allow us to find it). Any more info you could give about your platform would be useful (OS, are you using a virtualenv, where is the virtualenv stored if so, etc). |
Sorry, it's not open source, but I can try to provide as many details as you need. OS:
Virtualenv: pyenv-virtualenv and using Relevant vscode settings:
An important detail may be our directory structure which is non-standard. This is a django project. We contain our apps within an internal
In this way, we refer to our apps like:
Some files use Please let me know if there's any further information that would be beneficial. |
Could this possibly be caused by the python-future library, which defines a module called I can provide the AnalysisLog if you think that could be useful. |
I was able to get it (exactly once) without importing anything, so I don't think it's necessarily one library or another. Installing the future package and importing a few different ways doesn't trigger anything either. Right now, I think I'm just going to do something like in #429 and hardcode a few known-defined names until we can figure out the actual cause. The code that produces these messages is going to get completely remove as we simplify the codebase, so the bug may also disappear as well. |
@jarshwah If you've been able to reliably get True/False to show as use-before-def, would you mind trying out our daily build to see if the issue goes away? I added a temporary fix in #464 (not yet in stable). To move to the daily build, you can add this to your VS Code settings: "python.analysis.downloadChannel": "daily" If you want to go back to stable, you can remove that line and delete the folders with names starting with |
Unfortunately the language server is crashing for me now, as of version: Logs for version
|
FWIW - I've done some c# in my time. So if there are any decent "getting started with contributing" guides and some tests you'd like me to run, I'd be happy to do so. |
I just tested with "daily" and I got the same Error as @jarshwah posted. I then removed that config, but the error still happens.
There are no such folders in extensions:
I see various items in CachedData.
|
@crucialfelix you need to delete the language server folder from the python extension folder:
|
If you'd like to look yourself, we have instructions in CONTRIBUTING.md which should work on any platform. Since this is unrelated to the True/False issue, I've created #470 for that discussion. |
@jarshwah @crucialfelix The daily build now includes a fix for #470 (0.1.72.0), if you'd like to retest my temporary fix. |
Looks like that has done it, thanks! |
Great! I'm going to close this issue for now as the code that produces these warnings is slated to be removed/redone during our ongoing rewrite. We'll revisit this later just to make sure this sort of thing doesn't happen again with the new code. |
Fixes microsoft#442. Replaces microsoft#429, which only masks the underlying True/False bug in microsoft#391. I also removed the hack in microsoft#336 which checked for `ConstantExpression`.
microsoft/vscode-python#3274
This has been reported by at least 3 separate people (see the duplicate issue to the one above).
The text was updated successfully, but these errors were encountered: