Skip to content

Commit 5a0c2fb

Browse files
author
hauntsaninja
committed
modulefinder: make -p handle namespace packages correctly
Fixes part of python#5759 The other part is passing files arguments, which we make steps towards in python#9614
1 parent 8e7407c commit 5a0c2fb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mypy/modulefinder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,13 @@ def find_modules_recursive(self, module: str) -> List[BuildSource]:
387387
if mod not in hits:
388388
hits.add(mod)
389389
result += self.find_modules_recursive(module + '.' + mod)
390-
elif os.path.isdir(module_path) and module in self.ns_packages:
391-
# Even more subtler: handle recursive decent into PEP 420
390+
elif os.path.isdir(module_path) and any(module.startswith(p) for p in self.ns_packages):
391+
# Even subtler: handle recursive decent into PEP 420
392392
# namespace packages that are explicitly listed on the command
393393
# line with -p/--packages.
394394
for item in sorted(self.fscache.listdir(module_path)):
395-
if os.path.isdir(os.path.join(module_path, item)):
396-
result += self.find_modules_recursive(module + '.' + item)
395+
item, _ = os.path.splitext(item)
396+
result += self.find_modules_recursive(module + '.' + item)
397397
return result
398398

399399

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy