|
15 | 15 | from mypy import defaults |
16 | 16 | from mypy import experiments |
17 | 17 | from mypy import util |
18 | | -from mypy.build import BuildSource, BuildResult, SearchPaths |
| 18 | +from mypy.build import BuildResult |
| 19 | +from mypy.modulefinder import BuildSource, FindModuleCache, mypy_path, SearchPaths |
19 | 20 | from mypy.find_sources import create_source_list, InvalidSourceList |
20 | 21 | from mypy.fscache import FileSystemCache |
21 | 22 | from mypy.errors import CompileError |
@@ -453,6 +454,10 @@ def add_invertible_flag(flag: str, |
453 | 454 | imports_group.add_argument( |
454 | 455 | '--no-silence-site-packages', action='store_true', |
455 | 456 | help="Do not silence errors in PEP 561 compliant installed packages") |
| 457 | + add_invertible_flag( |
| 458 | + '--namespace-packages', default=False, |
| 459 | + help="Support namespace packages (PEP 420, __init__.py-less)", |
| 460 | + group=imports_group) |
456 | 461 |
|
457 | 462 | platform_group = parser.add_argument_group( |
458 | 463 | title='Platform configuration', |
@@ -880,14 +885,14 @@ def add_invertible_flag(flag: str, |
880 | 885 | # Set target. |
881 | 886 | if special_opts.modules + special_opts.packages: |
882 | 887 | options.build_type = BuildType.MODULE |
883 | | - search_paths = SearchPaths((os.getcwd(),), tuple(build.mypy_path()), (), ()) |
| 888 | + search_paths = SearchPaths((os.getcwd(),), tuple(mypy_path()), (), ()) |
884 | 889 | targets = [] |
885 | 890 | # TODO: use the same cache that the BuildManager will |
886 | | - cache = build.FindModuleCache(fscache) |
| 891 | + cache = FindModuleCache(search_paths, fscache) |
887 | 892 | for p in special_opts.packages: |
888 | 893 | if os.sep in p or os.altsep and os.altsep in p: |
889 | 894 | fail("Package name '{}' cannot have a slash in it.".format(p)) |
890 | | - p_targets = cache.find_modules_recursive(p, search_paths, options.python_executable) |
| 895 | + p_targets = cache.find_modules_recursive(p) |
891 | 896 | if not p_targets: |
892 | 897 | fail("Can't find package '{}'".format(p)) |
893 | 898 | targets.extend(p_targets) |
|
0 commit comments