I'm seeing behavior where the Pyright backend is c...
# general
a
I'm seeing behavior where the Pyright backend is caching at the granularity of the top-level call. E.g. if I call
Copy code
pants check my_package/::
and get a successful result, the a repeat of that call will return a cached result, but if I edit any file within
my_package/::
, a new call to
pants check
will run against all files again, even if the changed file is a leaf node in the larger dependency tree. Is this the expected caching behavior of the Pyright backend? Are there plans to make it granular to each source file?
b
Type checking usually has cross-file dependencies, eg if
file.py
has a
from .sibling import function
import, then type checking
file.py
needs
sibling.py
, and thus changes to
sibling.py
require type checking
file.py
too (and for all transitive downstream code too) So, the checking goals typically work at a whole-repo level. This can definitely be improved eg theoretically could happen in a vaguely per-file way, with appropriate support from pyright (since checking a file actually only needs the definitions from each import, doesn’t need to type check all their internal code) For mypy, pants has support for getting mypy to use it’s own cache, so that rechecking a barely-changed repo is still pretty fast (not as fast as unchanged of course). Does pyright have its own caching? If so, I don’t know if pants enables it
a
As far as I know Pyright only has an in-memory cache and the maintainers didn’t want to deal with cache invalidation
👍 1
Is it not feasible to cache at the per-target level by storing a digest of that target’s full dependency tree? Even a roughly per-folder cache would be a major improvement
e
@ancient-terabyte-9085 if you can find a way to run the
pyright
command line tool (^ with no daemon, i.e. not using
--watch
) that is faster, then it is probably possible and just needs more or less elbow grease since this is a volunteer driven project. It shouldn't be too hard to experiment with the
pyright
CLI and find the answer to 1st order. ^ Pants does not have easy support for daemon tools right now that stay up and running between Pants runs.
b
Yeah, sharding the type checking by "connected component"/directories of dependencies would probably be feasible. Feel free to a file a feature request issue, although, as John notes, Pants is volunteer driven so there may not be progress on it unless someone (maybe you 😄 ) feels inclined to pick it up.
👍 1