From 45af71e33bdfb2b2cfcab6cc776a7797c216ecb5 Mon Sep 17 00:00:00 2001 From: Riken Shah Date: Fri, 11 Jun 2021 19:24:36 +0000 Subject: [PATCH] clean_unused_caches: Allow the main function to accept `Namespace` args. This commit will allow us to pass the arguments in the 'clean...' functions when calling the `main` function (in `provision`). It also changes args parsing function location to `if __name__ == "__main__"` block as we wouldn't need it to parse args when we call the function. --- scripts/lib/clean_unused_caches.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/lib/clean_unused_caches.py b/scripts/lib/clean_unused_caches.py index ee09987f25..929f5beca8 100755 --- a/scripts/lib/clean_unused_caches.py +++ b/scripts/lib/clean_unused_caches.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import argparse import os import sys @@ -8,8 +9,7 @@ from scripts.lib import clean_emoji_cache, clean_node_cache, clean_venv_cache, c from scripts.lib.zulip_tools import parse_cache_script_args -def main() -> None: - args = parse_cache_script_args("This script cleans unused Zulip caches.") +def main(args: argparse.Namespace) -> None: os.chdir(ZULIP_PATH) clean_venv_cache.main(args) clean_node_cache.main(args) @@ -18,4 +18,5 @@ def main() -> None: if __name__ == "__main__": - main() + args = parse_cache_script_args("This script cleans unused Zulip caches.") + main(args)