Skip to content

Commit

Permalink
Keep track of fine-grained deps for modules in typeshed (#10034)
Browse files Browse the repository at this point in the history
Even if we assume that typeshed stubs don't change, we need the deps
when bringing in new stubs when following imports during a fine-grained
increment.

This fixes false positives when following imports to `six` and
`requests`.

Some modules are always part of the initial build, and we can still
skip generating deps for them, as an optimization.

I only tested this manually, since I couldn't figure out an easy way to
reproduce the issue in our tests.

Fixes #10033.
  • Loading branch information
JukkaL authored Feb 5, 2021
1 parent a1a74fe commit 55359ee
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2205,12 +2205,14 @@ def _patch_indirect_dependencies(self,

def compute_fine_grained_deps(self) -> Dict[str, Set[str]]:
assert self.tree is not None
if '/typeshed/' in self.xpath or self.xpath.startswith('typeshed/'):
# We don't track changes to typeshed -- the assumption is that they are only changed
# as part of mypy updates, which will invalidate everything anyway.
#
# TODO: Not a reliable test, as we could have a package named typeshed.
# TODO: Consider relaxing this -- maybe allow some typeshed changes to be tracked.
if self.id in ('builtins', 'typing', 'types', 'sys', '_typeshed'):
# We don't track changes to core parts of typeshed -- the
# assumption is that they are only changed as part of mypy
# updates, which will invalidate everything anyway. These
# will always be processed in the initial non-fine-grained
# build. Other modules may be brought in as a result of an
# fine-grained increment, and we may need these
# dependencies then to handle cyclic imports.
return {}
from mypy.server.deps import get_dependencies # Lazy import to speed up startup
return get_dependencies(target=self.tree,
Expand Down

0 comments on commit 55359ee

Please sign in to comment.