Skip to content

Commit

Permalink
Code review request
Browse files Browse the repository at this point in the history
  • Loading branch information
caponetto committed Aug 14, 2024
1 parent 6b4aafb commit 786c6d0
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions scripts/new_python_based_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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()

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 786c6d0

Please sign in to comment.