Skip to content

Commit 512d560

Browse files
chrimahoCopilot
andauthored
Fix missing .__name__ attribute
When accessing and formatting the type in the error message. This line should be `msg += f"Must be '{check_type.__name__}'"` to be consistent with line 647 in `assert_value_of_type()` and to produce cleaner error messages that show just the type name (e.g., `'int'`) rather than the full type object representation (e.g., `<class 'int'>`). Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 81b4053 commit 512d560

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/toolbox_python/checkers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def assert_all_values_of_type(values: Collection[Any], check_type: Union[type, C
737737
invalid_types: list[str] = [f"'{type(value).__name__}'" for value in values if not is_type(value, check_type)]
738738
msg: str = f"Some elements {invalid_values} have the incorrect type {invalid_types}. "
739739
if isinstance(check_type, type):
740-
msg += f"Must be '{check_type}'"
740+
msg += f"Must be '{check_type.__name__}'"
741741
else:
742742
types: list[str] = [f"'{typ.__name__}'" for typ in check_type]
743743
msg += f"Must be: {' or '.join(types)}"

0 commit comments

Comments
 (0)