Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mypy/find_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ def crawl_up(self, path: str) -> Tuple[str, str]:
if module_name == "__init__":
return parent_module, base_dir

# Note that module_name might not actually be a valid identifier, but that's okay
# Note that module_name might not actually be a valid identifier, but that's okay (once
# we've removed periods from module_name)
# Ignoring this possibility sidesteps some search path confusion
module_name = module_name.replace(".", "-")

module = module_join(parent_module, module_name)
return module, base_dir

Expand Down
6 changes: 6 additions & 0 deletions mypy/test/test_find_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def test_crawl_namespace_multi_dir(self) -> None:
assert crawl(finder, "/a/pkg/a.py") == ("pkg.a", "/a")
assert crawl(finder, "/b/pkg/b.py") == ("pkg.b", "/b")

def test_crawl_invalid_module(self) -> None:
options = Options()

finder = SourceFinder(FakeFSCache({"/dot.dot.py"}), options)
assert crawl(finder, "/dot.dot.py") == ("dot-dot", "/")

def test_find_sources_no_namespace(self) -> None:
options = Options()
options.namespace_packages = False
Expand Down