Make `_check_type` output the actual type in addition to the expected
type. Example:
Before: # TypeError: `.[0]."cond-id"`: expecting a string value
After: # TypeError: `.[0]."cond-id"`: expecting a string value, got an array
Change-Id: I9615aa380b12fe5e7fd65b079840b779f9530f3a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11781
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
def _check_type(val: Val, expected_type: Type[Val]):
if not isinstance(val, expected_type):
raise TypeError(
- "`{}`: expecting {} value".format(
- val.path, expected_type._name # pyright: ignore [reportPrivateUsage]
+ "`{}`: expecting {} value, got {}".format(
+ val.path,
+ expected_type._name, # pyright: ignore [reportPrivateUsage]
+ type(val)._name, # pyright: ignore [reportPrivateUsage]
)
)