From 6bfe898d7ec42ad9444511604f0c3bf3adbbac11 Mon Sep 17 00:00:00 2001 From: rechen Date: Fri, 9 Feb 2024 16:16:35 -0800 Subject: [PATCH] Ignore non-aliased module nodes when collecting dependencies. This fixes a failure in typeshed's pytype_test. PiperOrigin-RevId: 605760245 --- pytype/pytd/visitors.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pytype/pytd/visitors.py b/pytype/pytd/visitors.py index 354b24c8a..e354ed21a 100644 --- a/pytype/pytd/visitors.py +++ b/pytype/pytd/visitors.py @@ -1536,7 +1536,12 @@ def EnterLateType(self, node): self._ProcessName(node.name, self.late_dependencies) def EnterModule(self, node): - self._ProcessName(node.module_name, self.dependencies) + # Most module nodes look like: + # Module(name='foo_module.bar_module', module_name='bar_module'). + # We don't care about these. Nodes that don't follow this pattern are + # aliased modules, which we need to record. + if not node.name.endswith("." + node.module_name): + self._ProcessName(node.module_name, self.dependencies) def ExpandSignature(sig):