Skip to content
Merged
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 @@ -195,7 +195,10 @@ def _crawl_up_helper(self, dir: str) -> tuple[str, str] | None:
if not name.isidentifier():
# in most cases the directory name is invalid, we'll just stop crawling upwards
# but if there's an __init__.py in the directory, something is messed up
raise InvalidSourceList(f"{name} is not a valid Python package name")
raise InvalidSourceList(
f"{name} contains {os.path.basename(init_file)} "
"but is not a valid Python package name"
)
# we're definitely a package, so we always return a non-None value
mod_prefix, base_dir = self.crawl_up_dir(parent)
return module_join(mod_prefix, name), base_dir
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ dir/a.py:1: error: Name "undef" is not defined
[file dir/sub.pkg/a.py]
undef
[out]
sub.pkg is not a valid Python package name
sub.pkg contains __init__.py but is not a valid Python package name
== Return code: 2

[case testBadFileEncoding]
Expand Down