Erroneous warnings "constant not defined" issued by Pylance
This issue has been moved from a ticket on Developer Community.
[regression] [worked-in:VS 2022 17.1.x] Opening the repo mentioned here https://github.com/microsoft/pylance-release/issues/2427 with VS 17.2.0 not only yields the well known problems of VS continuously starting pylance and pylance not analyzing files in acceptable time but
Info: (2404) [BG(1)] Long operation: checking: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (494719ms) Info: (2404) [BG(1)] Long operation: analyzing: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (495780ms) Info: (2404) [BG(1)] Long operation: getSemanticTokens full at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (70756ms) Info: (2404) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1652737442062 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (70484ms) Info: (2404) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1652737513253 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (75193ms) Info: (2404) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1652737584122 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (68038ms) Info: (2404) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1652737659771 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (73477ms) Info: (2404) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1652737728122 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (72514ms) etc. etc.
in addition _583: warnings almost all of the type "constant X not defined" are issued with the code segments getting highlighted. These warnings are all incorrect as the constants are defined in a separate file and due to the associated code highlighting are rather annoying.
Original Comments
Feedback Bot on 5/16/2022, 07:35 PM:
(private comment, text removed)
Original Solutions
(no solutions)
(70484ms) is a really long time. something seems to be misconfigured in your repo. C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (70484ms)
is the code public?
can you add your logs? see https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue
Update report below now using Pylance language server 2022.5.3 and Version 17.3.0 Preview 2.0
As the reported execution time is fluctuates peaks at 4651372ms I have not provided logs. The code is available in a private repo which I made available as requested here https://github.com/microsoft/pyright/issues/3138. Please let me know if I should give access to someone else.
Any improvement in the run time will be appreciated. Most annoying to me is that warning and error messages do not get updated and fixed errors keep getting reported.
The code in quick_dominion.py has an error in line 5704 - "cation" instead of "action"
Info: (23020) Searching for source files Info: (23020) Found 7 source files Info: (23020) [BG(2)] Long operation: getSemanticTokens range 5650:0 - 5751:0 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (2829ms)
gives 0 errors and warnings
Info: (23020) [BG(2)] Long operation: checking: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (4651372ms) Info: (23020) [BG(2)] Long operation: analyzing: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (4651373ms) Info: (23020) [BG(2)] Long operation: getSemanticTokens full at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (23685ms)
gives 1 warning "cation" is not defined line 5704
Changing "action" to "cation" also in line 1972:
Info: (23020) [BG(2)] Long operation: getSemanticTokens full at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (23685ms) Info: (23020) [FG] Long operation: completion at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py:1971:42 (2545233ms) Info: (23020) [BG(2)] Long operation: getSemanticTokens delta previousResultId:1656337591804 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (42516ms) Info: (23020) [FG] Long operation: completion at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py:1971:41 (3424540ms)
yields no update of error/warnings
Fix line 5704 cation to action:
Info: (23020) [FG] Long operation: completion at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py:1971:42 (3494520ms) Info: (23020) [FG] Long operation: completion at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py:1971:43 (3208027ms) Info: (23020) [BG(2)] Long operation: getSemanticTokens delta previousResultId:1656338192514 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (37433ms) NodeJS. JaveScript Runtime running on about a core - lets stop this
no change: warning message about (the long ago fixed) line 5704 and still no message about line 1972
Update report below now using Pylance language server 2022.6.0 and Version 17.3.0 Preview 3.0
Retracing the steps from above, observed peak runtime per step now 6448636ms (+40%) and the first code analysis does not report the warning in line 5704 any more...
Info: (17884) Pylance language server 2022.6.30 (pyright 212d1465) starting Info: (17884) Background analysis(1) started Info: (17884) [BG(1)] Long operation: getSemanticTokens range 1925:0 - 2026:0 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (11968ms) Info: (17884) [BG(1)] Long operation: checking: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (11580ms) Info: (17884) [BG(1)] Long operation: analyzing: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (11580ms) Info: (17884) [BG(1)] Long operation: getSemanticTokens full at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (35018ms)
0 errors/warnings - CPU-Load goes down without issue in 5704 being found
Change "action" to "cation" in line 1972:
Info: (17884) [FG] Long operation: completion at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py:1971:41 (242242ms) Info: (17884) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1657689398137 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (55758ms) Info: (17884) [FG] Long operation: completion at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py:1971:43 (4209004ms)
still no errors/warnings
Info: (17884) [BG(1)] Long operation: checking: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (6448131ms) Info: (17884) [BG(1)] Long operation: analyzing: C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (6448636ms) Info: (17884) [BG(1)] Long operation: getSemanticTokens delta previousResultId:1657691847358 at C:\Users\Admin\Documents\Visual Studio 2019\Projects\pylancedemo\ai\quick_dominion.py (29058ms)
1 warning line 1972
Makes no sense to fix the undetected issue in 5704 so stopping here
Here's the next thing you can try. Add the following to the settings.json file for your project:
"python.analysis.logLevel": "Trace",
"python.analysis.logTypeEvaluationTime": true,
you should now see much more verbose output.
it might help track down where the time is being spent.
make sure to remove once you get a log
Closing old issue. If this is still a problem, please reopen with the information requested. thanks