You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
I have a fix for the None issue (see the followup comments in #429), but that's unrelated to the True/False issue. I've opened another issue (#442) to track the None bug separately from the True/False so we aren't mixing two different problems in this thread.
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).
An important detail may be our directory structure which is non-standard. This is a django project. We contain our apps within an internal apps subdirectory which we add to our PYTHONPATH in manage.py. See the structure below (heavily pruned):
Could this possibly be caused by the python-future library, which defines a module called builtins? I'm using this package in my project, and as I was checking the AnalysisLog I noticed a lot of entries regarding builtins.
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.
Josh Smeaton (@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 languageServer inside of the Python VS Code extension's directory.
Unfortunately the language server is crashing for me now, as of version: languageServer.0.1.69
Logs for version languageServer.0.1.71 below:
[Error - 5:37:55 PM] System.InvalidCastException: Unable to cast object of type 'Microsoft.PythonTools.Analysis.Values.BuiltinFunctionInfo' to type 'Microsoft.PythonTools.Analysis.Values.BuiltinClassInfo'.
at Microsoft.PythonTools.Analysis.PythonAnalyzer.GetBuiltinType(IPythonType type)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at Microsoft.PythonTools.Analysis.Values.Mro..ctor(IEnumerable`1 values)
at Microsoft.PythonTools.Analysis.Values.BuiltinClassInfo.get_Mro()
at Microsoft.PythonTools.Analysis.Values.Mro.Recompute()
at Microsoft.PythonTools.Analysis.Values.ClassInfo.SetBases(IEnumerable`1 bases)
at Microsoft.PythonTools.Analysis.ClassAnalysisUnit.AnalyzeWorker(DDG ddg, CancellationToken cancel)
at Microsoft.PythonTools.Analysis.Analyzer.DDG.Analyze(Deque`1 queue, CancellationToken cancel, Action`1 reportQueueSize, Int32 reportQueueInterval)
at Microsoft.PythonTools.Analysis.PythonAnalyzer.AnalyzeQueuedEntries(CancellationToken cancel)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.GroupAnalysis.Analyze(CancellationToken cancel)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumerLoop()
Hover in file:///Users/josh/dev/K3/kogan3/apps/some_gateway/models.py at (522, 28)
Waiting for parsing to complete.
Parsing complete. Waiting for analysis entries to enqueue.
Enqueue complete. Waiting for analysis to complete.
[Error - 5:42:11 PM] Request textDocument/definition failed.
Message: PriorityProducerConsumer`1 instance is disposed
Object name: 'PriorityProducerConsumer`1'.
Code: -32000
at Microsoft.PythonTools.Analysis.Infrastructure.DisposeToken.ThrowIfDisposed()
at Microsoft.PythonTools.Analysis.Infrastructure.PriorityProducerConsumer`1.Produce(T value, Int32 priority)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.ExecuteInQueueAsync(Func`2 function, AnalysisPriority priority)
at Microsoft.Python.LanguageServer.Implementation.Server.WaitForCompleteAnalysisWorker(CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.Server.FindReferences(ReferencesParams params, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.Server.GotoDefinition(TextDocumentPositionParams params, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.LanguageServer.GotoDefinition(JToken token, CancellationToken cancellationToken)
Getting hover for Order
Waiting for parsing to complete.
Parsing complete. Waiting for analysis entries to enqueue.
Enqueue complete. Waiting for analysis to complete.
[Error - 5:42:13 PM] Request textDocument/definition failed.
Message: PriorityProducerConsumer`1 instance is disposed
Object name: 'PriorityProducerConsumer`1'.
Code: -32000
at Microsoft.PythonTools.Analysis.Infrastructure.DisposeToken.ThrowIfDisposed()
at Microsoft.PythonTools.Analysis.Infrastructure.PriorityProducerConsumer`1.Produce(T value, Int32 priority)
at Microsoft.PythonTools.Intellisense.AnalysisQueue.ExecuteInQueueAsync(Func`2 function, AnalysisPriority priority)
at Microsoft.Python.LanguageServer.Implementation.Server.WaitForCompleteAnalysisWorker(CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.Server.FindReferences(ReferencesParams params, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.Server.GotoDefinition(TextDocumentPositionParams params, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.LanguageServer.GotoDefinition(JToken token, CancellationToken cancellationToken)
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 then removed that config, but the error still happens.
If you want to go back to stable, you can remove that line and delete the folders with names starting with languageServer inside of the Python VS Code extension's directory.
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.
Activity
ccaspers commentedon Nov 21, 2018
Probably related: the same happens for me with
None.KevOrr commentedon Dec 1, 2018
Fwiw I get the same with
Nonebeing used as an argument to a type annotationMWE:(see edit)'None'(the string) produces the same effect:TrueandFalsebeing substituted there don't produce the same effect:EDIT: Even more minimal MWE:
jakebailey commentedon Dec 1, 2018
I have a fix for the
Noneissue (see the followup comments in #429), but that's unrelated to the True/False issue. I've opened another issue (#442) to track theNonebug separately from the True/False so we aren't mixing two different problems in this thread.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).
Add None with type NoneType during builtin PostWalk (#447)
jarshwah commentedon Dec 3, 2018
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.
jakebailey commentedon Dec 3, 2018
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).
jarshwah commentedon Dec 3, 2018
Sorry, it's not open source, but I can try to provide as many details as you need.
OS:
OSX 10.13.6Python Version: built with pyenv
Virtualenv: pyenv-virtualenv and using
.python-versionin local directory to point to it.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
appssubdirectory which we add to our PYTHONPATH inmanage.py. See the structure below (heavily pruned):In this way, we refer to our apps like:
Some files use
from __future__ import absolute_importwhile others do not.Please let me know if there's any further information that would be beneficial.
jarshwah commentedon Dec 6, 2018
Could this possibly be caused by the python-future library, which defines a module called
builtins? I'm using this package in my project, and as I was checking the AnalysisLog I noticed a lot of entries regardingbuiltins.I can provide the AnalysisLog if you think that could be useful.
jakebailey commentedon Dec 6, 2018
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.
jakebailey commentedon Dec 7, 2018
Josh Smeaton (@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:
If you want to go back to stable, you can remove that line and delete the folders with names starting with
languageServerinside of the Python VS Code extension's directory.jarshwah commentedon Dec 8, 2018
Unfortunately the language server is crashing for me now, as of version:
languageServer.0.1.69Logs for version
languageServer.0.1.71below:jarshwah commentedon Dec 8, 2018
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.
crucialfelix commentedon Dec 8, 2018
I just tested with "daily" and I got the same Error as Josh Smeaton (@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.
jarshwah commentedon Dec 8, 2018
Chris Sattinger (@crucialfelix) you need to delete the language server folder from the python extension folder:
jakebailey commentedon Dec 8, 2018
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.
jakebailey commentedon Dec 11, 2018
Josh Smeaton (@jarshwah) Chris Sattinger (@crucialfelix) The daily build now includes a fix for #470 (0.1.72.0), if you'd like to retest my temporary fix.
jarshwah commentedon Dec 12, 2018
Looks like that has done it, thanks!
jakebailey commentedon Dec 12, 2018
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.
Add None with type NoneType during builtin PostWalk (microsoft#447)