Skip to content

Commit fd16f84

Browse files
authored
build: log build sources with -v (#9672)
With the changes I've been making to mypy's import handling, I think this would be a useful thing to add preemptively. Note that I would have found this very useful at points, and I think others would too, eg #7672 and #8584 The existing logging ignores source_modules and source_text and won't help with determining what mypy things the module name for a given file is, which is useful for namespace package issues as in the complaint in #8584. Co-authored-by: hauntsaninja <>
1 parent 7e66e51 commit fd16f84

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

mypy/build.py

+6-18
Original file line numberDiff line numberDiff line change
@@ -2541,37 +2541,25 @@ def skipping_ancestor(manager: BuildManager, id: str, path: str, ancestor_for: '
25412541
severity='note', only_once=True)
25422542

25432543

2544-
def log_configuration(manager: BuildManager) -> None:
2544+
def log_configuration(manager: BuildManager, sources: List[BuildSource]) -> None:
25452545
"""Output useful configuration information to LOG and TRACE"""
25462546

25472547
manager.log()
25482548
configuration_vars = [
25492549
("Mypy Version", __version__),
25502550
("Config File", (manager.options.config_file or "Default")),
2551-
]
2552-
2553-
src_pth_str = "Source Path"
2554-
src_pths = list(manager.source_set.source_paths.copy())
2555-
src_pths.sort()
2556-
2557-
if len(src_pths) > 1:
2558-
src_pth_str += "s"
2559-
configuration_vars.append((src_pth_str, " ".join(src_pths)))
2560-
elif len(src_pths) == 1:
2561-
configuration_vars.append((src_pth_str, src_pths.pop()))
2562-
else:
2563-
configuration_vars.append((src_pth_str, "None"))
2564-
2565-
configuration_vars.extend([
25662551
("Configured Executable", manager.options.python_executable or "None"),
25672552
("Current Executable", sys.executable),
25682553
("Cache Dir", manager.options.cache_dir),
25692554
("Compiled", str(not __file__.endswith(".py"))),
2570-
])
2555+
]
25712556

25722557
for conf_name, conf_value in configuration_vars:
25732558
manager.log("{:24}{}".format(conf_name + ":", conf_value))
25742559

2560+
for source in sources:
2561+
manager.log("{:24}{}".format("Found source:", source))
2562+
25752563
# Complete list of searched paths can get very long, put them under TRACE
25762564
for path_type, paths in manager.search_paths._asdict().items():
25772565
if not paths:
@@ -2591,7 +2579,7 @@ def dispatch(sources: List[BuildSource],
25912579
manager: BuildManager,
25922580
stdout: TextIO,
25932581
) -> Graph:
2594-
log_configuration(manager)
2582+
log_configuration(manager, sources)
25952583

25962584
t0 = time.time()
25972585
graph = load_graph(sources, manager)

mypy/modulefinder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(self, path: Optional[str], module: Optional[str],
8585
self.base_dir = base_dir # Directory where the package is rooted (e.g. 'xxx/yyy')
8686

8787
def __repr__(self) -> str:
88-
return '<BuildSource path=%r module=%r has_text=%s base_dir=%s>' % (
88+
return 'BuildSource(path=%r, module=%r, has_text=%s, base_dir=%r)' % (
8989
self.path,
9090
self.module,
9191
self.text is not None,

0 commit comments

Comments
 (0)