in tools/upgrade/commands/expand_target_coverage.py [0:0]
def run(self) -> None:
local_root = self._local_configuration
local_root = Path(local_root) if local_root else Path.cwd()
# Do not change if configurations exist below given root
existing_configurations = find_files(local_root, ".pyre_configuration.local")
if existing_configurations and not existing_configurations == [
str(local_root / ".pyre_configuration.local")
]:
LOG.warning(
"Cannot expand targets because nested configurations exist:\n%s",
"\n".join(existing_configurations),
)
return
# Expand coverage
local_configuration = Configuration.find_local_configuration(local_root)
if not local_configuration:
LOG.warning("Could not find a local configuration to codemod.")
return
LOG.info("Expanding typecheck targets in `%s`", local_configuration)
configuration = Configuration(local_configuration)
existing_targets = configuration.targets
glob_target = "//{}/...".format(str(local_root))
if existing_targets == [glob_target]:
LOG.info("Configuration is already fully expanded.")
return
configuration.add_targets([glob_target])
configuration.deduplicate_targets()
configuration.write()
# Suppress errors
self._get_and_suppress_errors(
configuration,
error_source=ErrorSource.GENERATE,
fixme_threshold=self._fixme_threshold,
fixme_threshold_fallback_mode=LocalMode.IGNORE,
)
self._repository.commit_changes(
commit=(not self._no_commit),
title=f"Expand target type coverage in {local_root}",
summary="Expanding type coverage of targets in configuration.",
set_dependencies=False,
)