in tools/upgrade/upgrade.py [0:0]
def run(repository: Repository) -> None:
parser = argparse.ArgumentParser(fromfile_prefix_chars="@")
parser.add_argument("--verbose", action="store_true", help="Enable verbose logging")
commands = parser.add_subparsers()
# Subcommands: Codemods
missing_overridden_return_annotations = commands.add_parser(
"missing-overridden-return-annotations",
help="Add annotations according to errors inputted through stdin.",
)
MissingOverrideReturnAnnotations.add_arguments(
missing_overridden_return_annotations
)
missing_global_annotations = commands.add_parser(
"missing-global-annotations",
help="Add annotations according to errors inputted through stdin.",
)
MissingGlobalAnnotations.add_arguments(missing_global_annotations)
# Subcommand: Change default pyre mode to strict and adjust module headers.
strict_default = commands.add_parser("strict-default")
StrictDefault.add_arguments(strict_default)
# Subcommand: Set global configuration to given hash, and add version override
# to all local configurations to run previous version.
update_global_version = commands.add_parser("update-global-version")
GlobalVersionUpdate.add_arguments(update_global_version)
# Subcommand: Set global configuration `pysa_version` to given hash
update_pysa_version = commands.add_parser("update-pysa-version")
PysaVersionUpdate.add_arguments(update_pysa_version)
# Subcommand: Fixme all errors inputted through stdin.
fixme = commands.add_parser("fixme")
Fixme.add_arguments(fixme)
# Subcommand: Fixme all errors for a single project.
fixme_single = commands.add_parser("fixme-single")
FixmeSingle.add_arguments(fixme_single)
# Subcommand: Fixme all errors in all projects with local configurations.
fixme_all = commands.add_parser("fixme-all")
FixmeAll.add_arguments(fixme_all)
# Subcommand: Remove targets integration and replace with configuration
targets_to_configuration = commands.add_parser("targets-to-configuration")
TargetsToConfiguration.add_arguments(targets_to_configuration)
# Subcommand: Expand target coverage in configuration up to given error limit
expand_target_coverage = commands.add_parser("expand-target-coverage")
ExpandTargetCoverage.add_arguments(expand_target_coverage)
# Subcommand: Consolidate nested local configurations
consolidate_nested_configurations = commands.add_parser("consolidate-nested")
ConsolidateNestedConfigurations.add_arguments(consolidate_nested_configurations)
# Subcommand: Attempt remediation on broken configuration.
fix_configuration = commands.add_parser("fix-configuration")
FixConfiguration.add_arguments(fix_configuration)
enable_source_database_buck_builder = commands.add_parser(
"enable-source-database-buck-builder"
)
EnableSourceDatabaseBuckBuilder.add_arguments(enable_source_database_buck_builder)
support_sqlalchemy = commands.add_parser("support-sqlalchemy")
SupportSqlalchemy.add_arguments(support_sqlalchemy)
enable_new_server = commands.add_parser("enable-new-server")
EnableNewServer.add_arguments(enable_new_server)
# Initialize default values.
arguments = parser.parse_args()
if not hasattr(arguments, "command"):
# Reparsing with `fixme` as default subcommand.
arguments = parser.parse_args(sys.argv[1:] + ["fixme"])
logging.basicConfig(
format="%(asctime)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
level=logging.DEBUG if arguments.verbose else logging.INFO,
)
try:
exit_code = ExitCode.SUCCESS
arguments.command(arguments, repository).run()
except UnstableAST as error:
LOG.error(str(error))
exit_code = ExitCode.FOUND_ERRORS
except UserError as error:
LOG.error(str(error))
exit_code = ExitCode.FAILURE
except Exception as error:
LOG.error(str(error))
LOG.debug(traceback.format_exc())
exit_code = ExitCode.FAILURE
sys.exit(exit_code)