Skip to content

Commit

Permalink
modulefinder: make -p handle namespace packages correctly
Browse files Browse the repository at this point in the history
Fixes part of python#5759
The other part is passing files arguments, which we make steps towards
in python#9614
  • Loading branch information
hauntsaninja committed Oct 19, 2020
1 parent 8e7407c commit 5a0c2fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
if mod not in hits:
hits.add(mod)
result += self.find_modules_recursive(module + '.' + mod)
elif os.path.isdir(module_path) and module in self.ns_packages:
# Even more subtler: handle recursive decent into PEP 420
elif os.path.isdir(module_path) and any(module.startswith(p) for p in self.ns_packages):
# Even subtler: handle recursive decent into PEP 420
# namespace packages that are explicitly listed on the command
# line with -p/--packages.
for item in sorted(self.fscache.listdir(module_path)):
if os.path.isdir(os.path.join(module_path, item)):
result += self.find_modules_recursive(module + '.' + item)
item, _ = os.path.splitext(item)
result += self.find_modules_recursive(module + '.' + item)
return result


Expand Down

0 comments on commit 5a0c2fb

Please sign in to comment.