|
22 | 22 | from mypy.errors import CompileError |
23 | 23 | from mypy.find_sources import InvalidSourceList, create_source_list |
24 | 24 | from mypy.fscache import FileSystemCache |
25 | | -from mypy.modulefinder import BuildSource, FindModuleCache, SearchPaths, get_search_dirs, mypy_path |
| 25 | +from mypy.modulefinder import ( |
| 26 | + BuildSource, |
| 27 | + FindModuleCache, |
| 28 | + ModuleNotFoundReason, |
| 29 | + SearchPaths, |
| 30 | + get_search_dirs, |
| 31 | + mypy_path, |
| 32 | +) |
26 | 33 | from mypy.options import INCOMPLETE_FEATURES, BuildType, Options |
27 | 34 | from mypy.split_namespace import SplitNamespace |
28 | 35 | from mypy.version import __version__ |
@@ -1413,7 +1420,15 @@ def set_strict_flags() -> None: |
1413 | 1420 | fail(f"Package name '{p}' cannot have a slash in it.", stderr, options) |
1414 | 1421 | p_targets = cache.find_modules_recursive(p) |
1415 | 1422 | if not p_targets: |
1416 | | - fail(f"Can't find package '{p}'", stderr, options) |
| 1423 | + reason = cache.find_module(p) |
| 1424 | + if reason is ModuleNotFoundReason.FOUND_WITHOUT_TYPE_HINTS: |
| 1425 | + fail( |
| 1426 | + f"Package '{p}' cannot be type checked due to missing py.typed marker. See https://mypy.readthedocs.io/en/stable/installed_packages.html for more details", |
| 1427 | + stderr, |
| 1428 | + options, |
| 1429 | + ) |
| 1430 | + else: |
| 1431 | + fail(f"Can't find package '{p}'", stderr, options) |
1417 | 1432 | targets.extend(p_targets) |
1418 | 1433 | for m in special_opts.modules: |
1419 | 1434 | targets.append(BuildSource(None, m, None)) |
|
0 commit comments