-
Notifications
You must be signed in to change notification settings - Fork 133
print, others flagged as "Undefined variable" (requests being handled before initialization is complete?) #1697
Comments
Could you please provide the logs asked for in the template? I'd like to see the caching level you are using. |
Hi Jake. Thanks for the response. I think you want me to follow: So I did Python › Analysis: Log Level And Here's Output.Python:
I hope this is what you wanted. |
I just did a second run of my program just to be sure. Here's Output.python again.
|
I see, you don't have trace logging enabled and I think you're in the wrong output tab. Add |
Hi Jake. Thanks for your patience. I just
I reopened the "offending" program == test_jsonschema.py & NOW print IS NOT FLAGGED as Undefined variable! How time flies when you're having fun! I just ran test_jsonschema.py Now i open OUTPUT & select THE SECOND Python Language Server entry in the dropdown. N.B. the first had no output in the window. Here is what the OUTPUT window says: I am attaching the output as vscodePyLangServerLog.txt |
Caching is disabled in those logs, so that's interesting. Reloading fixing it doesn't surprise me, as the analysis will have been rerun. |
I am having a similar issue with inbuilt functions and types such as |
Changing the logging setting wouldn't have any effect. If you reloaded the editor when you changed the setting, the reload is what would have likely fixed it. |
I'm having the same problem of "print" being marked as an undefined variable. Trace output attached. |
I can confirm this problem. I am having it for all built-ins (dict, len, print, list, ...) ?
|
To be clear, after disabling caching, did you restart the language server? I don't know if we currently handle the case of going from caching to no caching within the same run (the other way would work, though be less efficient). |
Thanks. I did restart. Also, I find BTW, analyzing in background is now very slow. It takes hours to finish and afterward, I am having the |
I'm having the same problem, but reloading resolves it. For now I have to reload every hour or so. |
Essentially this appears to be happening to anything that's declared in the global scope; things like Working on #1601 and #1414 may preclude this, since they affect the analysis order. |
IMO what might be happening is that general analysis begins when |
Another reason is if somehow scraped/generated builtins stub is not written correctly. One way to try is to delete all cache. Path is output in the Output window like
And/or look if Perhaps like this
Cache now should contain one |
"Now i open OUTPUT & select THE SECOND Python Language Server entry in the dropdown. N.B. the first had no output in the window." |
Don't we define |
I was able to simulate the error by not having builtins analysis running. private void SpecializeFuture(FromImportStatement node) {
if (Interpreter.LanguageVersion.Is3x()) {
return;
} However, we do specialize say, |
From #1601 - looks like builtins got analyzed pretty late. |
Very weird. There's no reason for this to be happening since the builtin analysis should be blocking on initalization... |
Well, there were other issues similar to this when initialization didn't seem to block... Maybe same thing? |
#1741: (builtins are getting reanalyzed)
But there is no squiggle on builtins. |
More evidence of requests being handled before the initial startup:
This is still happening. The only thing that can be null at line 37 is the If microsoft/language-server-protocol#567 (comment) ever happens, we could not do the two-step init process when possible, but our current code should be working. |
Some time ago I wrote some extra tests for prioritizer, but they appeared to pass... |
One thing I found is that |
|
I've tried adding I am using Code Insiders with WSL remote against Ubuntu 18.04. Is there a different place to set the download channel when remoting against WSL? |
I've found ~/.vscode/settings.json in my WSL distro and added the line to that file. I've restarted VS Code Insiders but the Python Language Server is still 0.4.71.0. |
@MikhailArkhipov well, I've added the required line to my settings and restarted VS Code and it is not downloading a newer version of the Language Server, so I'm not sure what I can do in order to help @jakebailey with testing his fix ... unless it isn't supposed to be the beta channel? |
Which version is supposed to be in beta, 0.4.99.0? B/c i still get funky warnings like |
@pcolmer You may need to force an update by removing the old version. The extension may not be checking for an update as often as you need. You can find some instructions on how to find the folder here: microsoft/vscode-python#3977 @michaelaye That doesn't sound like the same issue. Maybe #1573, but that issue is old and I think actually related to #1601. |
No improvement for me. Builtins are still undefined and analyzing in background gets stuck. It seems that this only happens in big projects. I have no problems in smaller (less number of files) project. |
Another possible reason is that cached generated stub for However, I still see
way at the end. This is the root, IMO. |
No change. I removed the cache and restarted Code. Right after the restart, the builtins were correctly flagged showing their correct doc strings. A cup of coffee later, the builtins are again flagged as undefined variable. |
Could you try daily channel with 0.4.121? https://github.com/microsoft/python-language-server/wiki/Versioning-and-download-channels |
Version 0.4.121 fixed it for me. However, I almost never see the doc string because it's constantly analyzing. |
Now it's stuck in a reload loop. Note:
Somehow your workspace is a symlink to somewhere completely different outside of the workspace? What kind of setup do you have in your pythonpath? This seems very unusual. Try setting |
There are no symlinks in the workspace but |
resolved it. But also changing the workspace root to the direct path.
|
OK, since reload is a different issue, I am going to close this one which is about builtins. Feel free to open new issue on reloads. |
as the symptom is that builtins are wrongly flagged as not defined, i don't see why this issue is being closed. the problem is still there, isn't it? That the underlying reason maybe (i don't know i'm not the developer) has nothing to do with built-ins isn't really the user's problem. |
The builtins were being flagged as undefined as they hadn't been properly created, meaning users of the builtin wouldn't see that they exist and then show messages. Indefinite reloads may or may not cause that issue (usually not, just infinite analysis), and IMO are not necessarily related. The infinite reload observed above was described as "the docstrings don't show up", not "things are shown as undefined"; if the analysis never completes it won't show linting messages. If it completes with bad state, then you'll get wrong messages, which is what the original issue described and should be fixed with the merged PR. |
I can see that you mentioned If your issue persists, then we'd appreciate a new issue to take a look. (We prefer new issues that we can triage and merge, rather than lumping similar symptoms together in a single never-closed issue.) |
|
Environment data
Expected behaviour
print should NOT be flagged as "Undefined variable"
Actual behaviour
print is flagged as "Undefined variable"
Logs
Code Snippet / Additional lnformation
The text was updated successfully, but these errors were encountered: