From 786c6d0c12c61d8f073c472a62cd920e7774f31e Mon Sep 17 00:00:00 2001 From: Guilherme Caponetto <638737+caponetto@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:21:11 -0300 Subject: [PATCH] Code review request --- scripts/new_python_based_image.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/scripts/new_python_based_image.py b/scripts/new_python_based_image.py index 04557840a..96db89ab3 100644 --- a/scripts/new_python_based_image.py +++ b/scripts/new_python_based_image.py @@ -40,14 +40,6 @@ class Args: match: str log_level: str - def __str__(self): - return (f"Arguments:\n" - f"Context Directory: {self.context_dir}\n" - f"Source Version: {self.source}\n" - f"Target Version: {self.target}\n" - f"Match: '{self.match}'\n" - f"Log Level: {self.log_level}") - def extract_input_args() -> Args: """ @@ -75,7 +67,7 @@ def extract_input_args() -> Args: help="The string to match with the paths to base the new image from.") parser.add_argument( "--log-level", default="INFO", - help="Set the logging level. Default: %(default)s).") + help="Set the logging level. Default: %(default)s.") args = parser.parse_args() @@ -88,7 +80,7 @@ def extract_input_args() -> Args: return Args(args.context_dir, args.source, args.target, args.match, args.log_level) -def extract_python_version(version: str) -> list: +def extract_python_version(version: str) -> list[str]: """ Extracts the major and minor version components from a Python version string. @@ -175,7 +167,7 @@ def check_requirements(args: Args): check_pipenv_installed() -def find_matching_paths(context_dir: str, source_version: str, match: str) -> list: +def find_matching_paths(context_dir: str, source_version: str, match: str) -> list[str]: """ Finds directories in the context directory that match the specified source version and match criteria. @@ -215,7 +207,7 @@ def find_matching_paths(context_dir: str, source_version: str, match: str) -> li return [p for p in matching_paths if source_version in p] -def replace_python_version_on_paths(paths_list: list, source_version: str, target_version: str) -> dict: +def replace_python_version_on_paths(paths_list: list, source_version: str, target_version: str) -> dict[str, str]: """ Replaces occurrences of the source Python version with the target version in a list of paths. @@ -230,7 +222,7 @@ def replace_python_version_on_paths(paths_list: list, source_version: str, targe return {path: path.replace(source_version, target_version) for path in paths_list} -def copy_paths(paths_dict: dict) -> tuple: +def copy_paths(paths_dict: dict) -> tuple[list[str], list[str]]: """ Copies directories from source paths to destination paths. @@ -416,7 +408,7 @@ def rename_file_and_replace_python_version(path, filename, source_version, targe is_file=False) -def process_paths(copied_paths: list, source_version: str, target_version: str) -> tuple: +def process_paths(copied_paths: list, source_version: str, target_version: str) -> tuple[list[str], list[str]]: """ Processes the list of copied paths by replacing Python versions and running `pipenv lock` on Pipfiles. @@ -442,7 +434,7 @@ def process_paths(copied_paths: list, source_version: str, target_version: str) return success_processed, failed_processed -def process_pipfiles(path: str, target_version: str) -> tuple: +def process_pipfiles(path: str, target_version: str) -> tuple[list[str], list[str]]: """ Processes Pipfiles in a given path by running `pipenv lock` on them. @@ -496,7 +488,7 @@ def run_pipenv_lock(pipfile_path: str, target_version: str) -> bool: return False -def manual_checks() -> list: +def manual_checks() -> list[str]: """ Provides a list of manual checks to perform after the script execution.