From b72a44eb4ca5f650e9ebe1921e24c12deaa3bb76 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Dec 2025 12:30:09 +0000 Subject: [PATCH] Fix code review feedback - improve error handling and remove redundant checks - Use getattr to safely access __name__ attribute for better type error messages - Remove redundant type checks for sys.argv elements (guaranteed to be strings) Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- Programs/_freeze_module.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Programs/_freeze_module.py b/Programs/_freeze_module.py index 3099ecb..e41591a 100644 --- a/Programs/_freeze_module.py +++ b/Programs/_freeze_module.py @@ -31,8 +31,10 @@ def _check_type(value, expected_type, param_name: str) -> None: TypeError: If the value doesn't match the expected type """ if not isinstance(value, expected_type): + # Handle types that may not have __name__ attribute + type_name = getattr(expected_type, '__name__', str(expected_type)) raise TypeError( - f"Parameter '{param_name}' must be of type {expected_type.__name__}, " + f"Parameter '{param_name}' must be of type {type_name}, " f"got {type(value).__name__}" ) @@ -171,11 +173,6 @@ def main() -> None: name: str = sys.argv[1] inpath: str = sys.argv[2] outpath: str = sys.argv[3] - - # Validate that arguments are strings - _check_type(name, str, "name") - _check_type(inpath, str, "inpath") - _check_type(outpath, str, "outpath") text: bytes = read_text(inpath) marshalled: bytes = compile_and_marshal(name, text)