From e8979dedb8cb64891b36362e182ffed83252b63e Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 18 Nov 2023 22:37:03 -0800 Subject: [PATCH] clean up function exception formatter --- .../script/utils/exception_formatters.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ytdl_sub/script/utils/exception_formatters.py b/src/ytdl_sub/script/utils/exception_formatters.py index b10709b4..a76b3ecc 100644 --- a/src/ytdl_sub/script/utils/exception_formatters.py +++ b/src/ytdl_sub/script/utils/exception_formatters.py @@ -123,12 +123,7 @@ class FunctionArgumentsExceptionFormatter: return f"({self._to_human_readable_name(self._varargs)}, ...)" return "()" - def highlight(self) -> IncompatibleFunctionArguments: - """ - Returns - ------- - Exception with human-readable error highlighting for incompatible function arguments - """ + def _received_args_str(self) -> str: received_type_names: List[str] = [] for arg in self._input_args: if isinstance(arg, TypeHintedFunctionType): @@ -143,9 +138,15 @@ class FunctionArgumentsExceptionFormatter: else: received_type_names.append(arg.type_name()) - received_args_str = f"({', '.join(name for name in received_type_names)})" + return f"({', '.join(name for name in received_type_names)})" + def highlight(self) -> IncompatibleFunctionArguments: + """ + Returns + ------- + Exception with human-readable error highlighting for incompatible function arguments + """ return IncompatibleFunctionArguments( f"Incompatible arguments passed to function {self._name}.\n" - f"Expected {self._expected_args_str()}\nReceived {received_args_str}" + f"Expected {self._expected_args_str()}\nReceived {self._received_args_str()}" )