-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running pyright on a full workspace does not seem to report all existing errors. #9642
Comments
Thanks for the detailed analysis. Here's a few additional questions:
|
Oh, I think I see what's going on here. You mentioned that My recommendation is that you don't attempt to manually split up the type checking for your repo. Just check the entire repo and use If you do split up type checking, you'll need to de-duplicate the resulting diagnostics yourself. You can do this by using the I'm going to close the issue because I'm pretty confident this explains the behaviors you're seeing, and pyright is working as intended here. If you think that I've missed something, feel free to reply. |
Thanks for the very prompt response, @erictraut .
We are using a sole
No.
No.
I run pyright at the root folder, and made sure all tests ran to gather the data for the issue report were run from the root folder.
The bulk of the errors reported only when checking files independently ( Here is the table summing grouping all errors in
Note: like in my previous reply, these runs check only files in Looking at the actual files from where the errors were reported shows 108 files had errors reported only when scanning independently. Here's a Venn diagram of the following data:
This is what ultimately made me run pyright on each file independently ( The large number of [Edit:] I found something interesting in 5 files:
|
Thanks for the additional details. Reopening because it does appear there's something unexpected going on here. |
Describe the bug
I am seeing some puzzling behaviour in pyright where the number of errors reported varies depending on how checks are launched. That is, launching pyright on a workspace with ~6K files will miss errors that are found when the same files are checked in small batches or individually. In the tests below, I saw more than 360 errors reported when checking files independently that are missed when launching pyright on the workspace.
The expectation is that a typing error in a file would be reported regardless of whether that file was being checked independently, or as part of a larger list of files.
Code or Screenshots
I apologize in advance that I cannot share details of our code, but I will try my best to describe the symptoms and maybe get some insights in how to debug it further. (I also apologize for the long writeup, I had some time to kill...)
Context
We have a large monorepo with the bulk of code in two folders, let's call them
org
andorg_dev
. There are some restrictions in importing relationships:org
can import fromorg
, notorg_dev
.org_dev
can import fromorg
andorg_dev
.org
andorg_dev
import from third party libraries (core python, pandas, numpy, etc).The number of python files in
org
andorg_dev
are 3600+ and 2400+ respectively.Originally we were running pyright on everything:
To speed things up we separted the run into each
org
andorg_dev
in parallel:We got our speed increase, but we also got more errors reported (bulk 216, split 107+123=230). When running pyright directly on the files with new errors reported, pyright indeed reported the errors. (Note: the high number of errors are there because I am testing on 1.1.391 for this report; with our running version, 1.1.365, we went from 0 errors to 20-ish.)
It would seem that some files were not being checked when running pyright on the whole codebase at once, and only checked when fewer files were being given to pyright. Is this expected? Does pyright have an upper limit on files it can check?
I then ran the checks with
--verbose --stats
and the stats report does suggest that all runs are inspecting the expected number of files (6175 = 3681+2494):Selecting a file with errors reported only when running on
org
, and inspecting how it appears in each run log shows something like:The above seems to suggest that the file is being checked (time of 38ms), but the report is not being output.
More experiments
To dig into this further, I ran three more experiments:
org
,org_dev
orboth
.--threads
(only onorg
tree).org
tree).Heap size test
Heap size
Our production heapsize is set to 8GB by using
NODE_OPTIONS="--max-old-space-size=8192"
. I ran the three checksboth
(org org_dev
),org
, andorg_dev
with heap sizes of 8192, 16384 and 24576. Interestingly,both
had a reduction of 6 errors, the rest went unchanged. That is, checkingorg
andorg_dev
separately always resulted in more errors reported than checking them both in one pyright run:Although heap size did account for the missing errors, it did make for some interesting plots of memory management:
Memory behaviour with 8GB heap size
Memory behaviour with 24GB heap size
Threads test
Threads
Code block for test
The results seem puzzling. With one thread, they are consistent at 107 errors reported; but when multithreading, no only do I get more reports than single threaded, but the number of reports can vary between runs! This is the output of the script above:
Here are some Venn diagrams showing the differences:
More threads result in more errors reported
In three runs, using one thread had consistent results.
Using five threads resulted in more errors reported with variability between runs.
Using 10 threads resulted in even more errors, but variability did not increase.
Check folders and files test
Further separating folders
Since scanning both
org
andorg_dev
gave slightly different results. I wanted to know whether splittingorg
into smaller chunks would have further effects.I did two runs, one launching pyright targetting each subdirectory of
org/
(40+ subdirs, "dirscan
") and one targetting every independent file in theorg/
tree (3500+ files, "filescan
").In short,
org
check reported more errors thandirscan
, butfilescan
reported even more errors. Here is a Venn diagram of the overlap:The large number of errors found with
filescan
seemed reminiscent of the run with 10 threads. Indeed, most of the errors are found by both, the 10 threads scan andfilescan
(although not all), here is the Venn diagram of the overlap:Conclusion
The Venn diagrams describing the overlap between
filescan
and 10 threads suggest that launching pyright on a workspace is indeed either failing to detect, or report (since--stats
does indicate a check time for underreported files), typing errors in the codebase.VS Code extension or command-line
The tests in this report were run using pyright command line version 1.1.391. Although similar behaviour was seen with previous versions.
The text was updated successfully, but these errors were encountered: